previous | index | next

Testing for List Membership

          (element? 8 (integers-from-to 1 15)) ⇒ #t

          (element? 20 (integers-from-to 1 15))
          Error: car expects argument of type <pair>; given ()
Q: What's the problem?

A: Forgot to deal with the empty list (the base case of the recursion).

Q: Can an item be an element of the empty list?


previous | index | next