joybee wrote:
(defvar a 3)
(defvar b 5)
(if (not (equal a b)) ((format t "not equal~%") (setq a 6) (setq b 10)))
I just wanted to elaborate on Ramarren's response. IF has this form:
Code: Select all
(if condition do-this else-do-this)
And functions have this form:
Some blocks let you do multiple statements. Others do not. Examples:
Code: Select all
(when t
(do-one-thing)
(do-a-second-thing)
(do-a-third-thing))
(if t
(do-only-one-thing)
(do-the-alternative-thing))
Here's a possible fix to your code, assuming you want to format and set a and b:
Code: Select all
(if (not (equal a b))
(progn
(format t "not equal~%")
(setq a 6)
(setq b 10)))
;; better
(when (not (equal a b))
(format t "not equal~%")
(setq a 6)
(setq b 10))
;; if you meant to set b if a and b ARE equal:
(if (not (equal a b))
(progn
(format t "not equal~%")
(setq a 6))
(setq b 10))
By the way, progn returns the value of the last function called in its list. If you wanted the first function's value returned, you could use prog1 instead.
~a