From: holly-cam.com
Subject: how do you call functions already defined above without history stack overflow?
Date: 
Message-ID: <20010521203950.03938.00000522@ng-cl1.aol.com>
I had a history stack overflow and I think its because I'm calling functions
that are defined above?

We weren't advised as to how you call functions... 
Let me give my example
I define the flip function and then the add function 
Then the t-todec function is supposed to take a two's compliment number
(binary) and then flip it and add one and then give the decimal value (negative
of course)

The flip function and the add function will work alone for sure  :-)
I reallllly appreciate ANY help!

(setf num 0)
(setf ex 0)
(setf newlist '())
    
(defun flip (binnum)

 (if (null binnum)
  newlist

   (progn (if (= 1 (first (last binnum))) ;; if digit is a 1
           (setf newlist (cons '0 newlist)) ;; then cons a 0
           (setf newlist (cons '1 newlist))) ;; otherwise digit was a 0 and
cons a 1
              (flip (butlast binnum))   )  ) )  

(setf carrybit 0)
(setf solution 0)
(setf newlist '())

(defun add (num1 num2)
 (if (or (null num1) (null num2))
     (cons carrybit newlist)

     (progn (setf solution (+ (+ (first (last num1)) (first (last num2)))
carrybit))

 (if (= solution 3)
         (progn (setf carrybit 1) (setf newlist (cons '1 newlist))))

 (if (= solution 2)
         (progn (setf carrybit 1) (setf newlist (cons '0 newlist))))
                
 (if (= solution 1)
         (progn (setf carrybit 0) (setf newlist (cons '1 newlist))))
                     
 (if (= solution 0)
         (progn (setf carrybit 0) (setf newlist (cons '0 newlist))))

 (add (butlast num1) (butlast num2)) ))))))))


(setf num 0)
(setf ex 0)
(setf newlist '())

(defun t-todec (negnum)

  (if (null negnum)
    num
      (progn (setf negum (flip negnum))
        (setf negnum (add negnum '(1)))
        (setf num (+ num (* (first (last negnum)) (expt 2 ex)))) ;;num=num+last
digit*2^ex
        (setf ex (+ ex 1)) ;;exponent++
        (t-todec (butlast negnum)))))
                    ***********************************
                           www.holly-cam.com