Why aren't these equivalent?
Posted: Wed Oct 22, 2008 1:56 pm
Hello, noob question here. I'm coding up some DO loop examples to help me understand it. I eventually got my example working, but I'm curious why a previous version did NOT work.
The working one:
The non-working one, that I thought would be equivalent:
The working one:
Code: Select all
(defun add-inputs ()
"Add a series of numbers from input"
(do ((input (get-integer-from-input) (get-integer-from-input))
(sum 0 (+ sum input)))
((= input 0) sum)))
Code: Select all
(defun add-inputs-broken ()
"Add a series of numbers from input"
(do ((input (get-integer-from-input))
(sum 0 (+ sum input)))
((= input 0) sum)
(setf input (get-integer-from-input))))