member
member
takes any value and a list, and searches the
list for that value. If it finds it, it returns a pointer to
the first pair whose car holds that value, i.e.,
the "rest" of the list starting at the point where the
searched-for item was found. If it is not found, #f
is returned. (The return value is therefore always either
a pair or the false object.)
(member 22 '(18 22 #f 300))
returns (22 #f 300)
.
Notice that member can be used either to find a value's location
in a list, or as a predicate to check whether the item is in
the list at all. Since pairs are true values, you can use
the result of member
in a conditional expression and it will
count as true if the item is found.
[ Maybe I should introduce strings and symbols here, moving some material from the tutorial chapter here and possibly expanding the tutorial with more examples. ]