CL-USER> (a-sum 0 3)
->> 6
I wrote this program :
(defun a-sum (x y)
(if (and (> x -1) (> y -1))
(do ((i 0 (1+ i))
(sum 0)
(num x))
((equal i (+ (- y x) 1)))
(setq sum (+ sum num))
(setq num (+ num 1))
sum)
(print " NOPE")))
put if I run it in the terminal it returns nil and not the answer stated above; can someone help with the problem so it returns the value then Boolean.
Consider what value(s) a function returns. It's the value of the last form evaluated. In your case, that appears to be a
door maybe asetqorprint(It's difficult to read as it's formatted now, and I don't have question edit privileges).In short, the form that's returning the value for the function looks to be one evaluated for side-effects instead of returning a value.