3 ms·
You lost an "if" there :). setf will complain on trying to set 5 to 7. What you meant is: (setf z (if (> x y) 5 7)) A nicer thing that I like about Lisp's
by TeMPOraL 9y ago
You lost an "if" there :). setf will complain on trying to set 5 to 7.
What you meant is:
(setf z (if (> x y) 5 7))
A nicer thing that I like about Lisp's "everything is an expression" is something that is considered as code smell by some:
(setf foo (or var (compute-default-value) +some-default-constant+))
This works in Common Lisp, where the only value considered logically false is NIL, because or will short-circuit (as expected), returning not T, but the value of the first logically true result.
So e.g.
(let ((a nil) (b 2) (c :foo))
(or a b c))
returns 2.