From: holly-cam.com
Subject: Re: simpler question  :-)   help!?
Date: 
Message-ID: <20010521170449.03931.00000529@ng-cl1.aol.com>
The one with progn?
A different error... 
Does it know binnum is a list?

>(setf num 0)
(setf ex 0)



(defun s-todec (binnum)

  (if (null binnum)
    nil
      (progn (setf num (+ num (* (last binnum) (expt 2 ex)))) ;;num=num+last
dig
it*2^ex
      (setf ex (+ ex 1)) ;;exponent++
      (s-todec (butlast binnum)))))
0

>
0

>

S-TODEC

>(s-todec '(1 0 1 1))

Error: (1) is not of type NUMBER.
Fast links are on: do (si::use-fast-links nil) for debugging
Error signalled by *.
Broken at *.  Type :H for Help.  

                    ***********************************
                           www.holly-cam.com

From: Barry Margolin
Subject: Re: simpler question  :-)   help!?
Date: 
Message-ID: <p7gO6.20$oZ4.1179@burlma1-snr2>
In article <·····························@ng-cl1.aol.com>,
holly-cam.com <········@aol.comnospam> wrote:
>Error: (1) is not of type NUMBER.
>Fast links are on: do (si::use-fast-links nil) for debugging
>Error signalled by *.
>Broken at *.  Type :H for Help.  

We're going around in circles.  Just a couple of messages ago you seemed to
understand that (last binnum) returns the last cons cell in the list, not
the last element of the list, so you need to use (first (last binnum)) to
get the element.

I think you're wasting your time trying to learn this through the
newsgroup.  You need some one-on-one tutoring, since you're confused about
some very basic stuff.  Doesn't your class have a Teaching Assistant who
can work with you?

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: holly-cam.com
Subject: Re: simpler question  :-)   help!?
Date: 
Message-ID: <20010521182056.03931.00000538@ng-cl1.aol.com>
I'm sorry you're right I should have used first of the last... 

Actually there is no TA for this course
and its over tomorrow... it had nothing to do with LISP he just likes LISP and
decided to give us a quick overview of it with simple things and then asked us
to know how to do these operations for the exam... so I'm trying to learn them
on my own and its pretty rough!

I just got through the very first thing and now I have to move on to much
harder functions  :(

I really appreciate your help because I have no where else to go!

I tried this and it worked

(setf num 0)
(setf ex 0)

(defun s-todec (binnum)

  (if (null binnum)
    num
      (progn (setf num (+ num (* (first (last binnum)) (expt 2 ex))))
;;num=num+last digit*2^ex
      (setf ex (+ ex 1)) ;;exponent++
      (s-todec (butlast binnum)))))
                    ***********************************
                           www.holly-cam.com