The most powerful method of accessing an element in a list is via a
combination of the car and cdr functions. There are other
functions which provide an easier way to get at the elements in a flat
list. These will usually be faster than a string of car and cdr
operations.
car function). If there are too few elements in the list
and no element number count can be found nil is returned.
(nth 3 '(0 1 2 3 4 5))
=> 3
(nth 0 '(foo bar)
=> foo
(nthcdr 3 '(0 1 2 3 4 5))
=> (3 4 5)
(nthcdr 0 '(foo bar))
=> (foo bar)
nil is returned.
(last '(1 2 3))
=> 3
(last '())
=> nil
equal to object. The tail of the list (the cons cell
whose car is the matched object) is then returned. If no elements match
object then the empty list nil is returned.
(member 'c '(a b c d e))
=> (c d e)
(member 20 '(1 2))
=> nil
member except that comparisons are
performed by the eq function not equal.
Go to the first, previous, next, last section, table of contents.