COND (an alternative to IF)
The COND form uses of a kind of abstraction from nested IF forms.
> (define (small-prime? n)
; Returns T if n is a small prime.
(cond ((= n 2) #t)
((= n 3) #t)
((= n 5) #t)
((= n 7) #t)
(#t #f) ) )
> (small-prime? 9)
#f
> (small-prime? 3)
#t
Previous slide
Next slide
Back to first slide
View graphic version