Combinations of car and cdr

Since combinations of car and cdr are frequently used, all combinations up to four uses of car and cdr are defined as functions of the form cxxxr:


(caar x)    = (car (car x))

(cadr x) = (car (cdr x))

(caddr x) = (car (cdr (cdr x)))

Rule: The operations closer to the argument are done first.

It's worth memorizing some common combinations:

car = first element of a list

cadr

= second element

caddr

= third element

cadddr

= fourth element

Contents    Page-10    Prev    Next    Page+10    Index