previous | index | next

Exercise 7.8a, p. 174

Desired behavior:
     (element-of? 'foo '(1 3 5 foo 9)) ⇒ #t

     (element-of? 'bar '(1 3 5 foo 9)) ⇒ #f
Another way to write it:
     (define element-of?
       (lambda (item lst)
         (cond ((null? lst)
                #f)
               ((equal? (car lst) item)
                #t)
               (else 
                (element-of? item (cdr lst))))))

previous | index | next