Reputation: 519
(define (number n)
(cond
[(< n 10) 5.0]
[(< n 20) 5]
[(< n 30) true]))
How would I add an else statement at the end?
[else false])
Thanks.
Upvotes: 2
Views: 672
Reputation: 235994
Like this:
(define (number n)
(cond
[(< n 10) 5.0]
[(< n 20) 5]
[(< n 30) true]
[else false]))
Just remember - the else
clause (if present) must be the last clause in a cond
form. If it was not explicitly written and none of the conditions hold, then #<void>
is returned.
Upvotes: 2