I am new to LISP, is there a way of using mod
with control structures, if
statements.
for instance having (if (mod 4 2) (+ 2 2) (- 9 2))
.
What does the expression return, 0
, nil
, T
?
I am new to LISP, is there a way of using mod
with control structures, if
statements.
for instance having (if (mod 4 2) (+ 2 2) (- 9 2))
.
What does the expression return, 0
, nil
, T
?
In Lisp, the only false value is nil
, so 0
is true.
Thus (mod 4 2)
returns 0 which is true which means that
(if (mod 4 2)
(+ 2 2)
(- 9 2))
returns 4, while
(if (/= 0 (mod 4 2))
(+ 2 2)
(- 9 2))
returns 7.