I tried to write a (simple, i.e. without eqan?
) one?
function like such:
(define one?
(lambda (n)
((= 1 n))))
But the above doesn't work though because when I call it like such:
(one? 1)
I get greeted with this error:
procedure application: expected procedure, given: #t (no arguments)
The correct way (from The Little Schemer) to write it is:
(define one?
(lambda (n)
(cond
(else (= 1 n)))))
Why is there a need to use a cond
with an else
clause, instead of just returning (= 1 n)
?