Extracting Parts of Lists

Parts of lists can be extracted by car and cdr. cdr is pronounced `` could-er''. These names come from the first implementation of Lisp, on an IBM 704 computer; they stood for Contents of the Address part of Register and Contents of the Decrement part of Register. Some Lisp dialects also allow the names first for car and rest for cdr.

(car '(a b c))          =  a
(car '((a) b c))        =  (a)
(car (car '((a) b c)))  =  a
(car 'a)                error
(car '())               error

(cdr '(a b c)) = (b c) (cdr '((a) b c)) = (b c) (cdr (cdr '(a b c))) = (c) (cdr (car '((a) b c))) = () (cdr 'a) error (cdr '()) error

Contents    Page-10    Prev    Next    Page+10    Index