COND (an alternative to IF)
The COND form uses of a kind of abstraction from nested IF forms.
> (defun small-prime-p (n)
"Returns T if n is a small prime."
(cond ((= n 2) t)
((= n 3) t)
((= n 5) t)
((= n 7) t)
(t nil) ) )
SMALL-PRIME-P
> (small-prime-p 9)
NIL
> (small-prime-p 3)
T
Previous slide
Next slide
Back to first slide
View graphic version