car, cdr, and others car, cdr, and
others — return specific elements of a list.
car (list)
cdr (list)
caar (list)
cadr (list)
cdar (list)
cddr (list)
caaar (list)
caadr (list)
cadar (list)
caddr (list)
cdaar (list)
cdadr (list)
cddar (list)
cdddr (list)
listAny list.
An element of the list or nil.
The car function returns the first element of a
list. The cdr function returns all of the list except
for the first element. The remaining functions in this group are simply
shortcuts for the common combinations of car and
cdr. The shortcut functions are read from left to
right as nested car and cdr calls.
Thus, a call to caddr (mylist) would be equivalent to
car (cdr
(cdr (mylist))). If the argument is not a list, the
result is nil. The
cdr function will only return a non-list result in
the case of a dotted pair.
Gamma>car(list(1,2));1Gamma>cdr(list(1,2));(2)Gamma>cdr(cons(1,2));2Gamma>caadr (list (1, list(2, 3, list(4, 5), 6)));2Gamma>cdadr (list (1, list(2, 3, list(4, 5), 6)));(3 (4 5) 6)Gamma>