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 working one:
(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)))
The non-working one, that I thought would be equivalent:
(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))))