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)
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)); 1 Gamma> cdr(list(1,2)); (2) Gamma> cdr(cons(1,2)); 2 Gamma> caadr (list (1, list(2, 3, list(4, 5), 6))); 2 Gamma> cdadr (list (1, list(2, 3, list(4, 5), 6))); (3 (4 5) 6) Gamma>
Copyright © 1995-2006 by Cogent Real-Time Systems, Inc. All rights reserved.