caaaar caaadr ... caddar cadddr
type: function (subr) location: built-in source file: xllist.c Common LISP compatible: yes supported on: all machines
(caaaar <expr> ) (caaadr <expr> ) (caadar <expr> ) ... (caddar <expr> ) (cadddr <expr> ) <expr> - a list or list expression
The CAAAAR, CAAADR ... CADDAR, CADDDR functions go through the list expression and perform a sequence of CAR/CDR operations. The sequence of operations is performed from right to left. So CAADDR does a CDR on the expression, followed by a CDR, followed by a CAR, followed by another CAR. If at any point the list is NIL, NIL is returned. If at anypoint a CAR operation is performed on an atom (as opposed to a list) an error is reported - "error: BAD ARGUMENT".
(setq mylist '( ( (a b) (c d) (e f) ) ; make a 3-level list ( (g h) (i j) (k l) ) ( (m n) (o p) (q r) ) ( (s t) (u v) (w x) ) ) ) (caaadr mylist) ; returns G (caadar mylist) ; returns C (cdadar mylist) ; returns (D) (cadadr mylist) ; returns (I J) (cdaddr mylist) ; returns ((O P) (Q R)) (cadddr mylist) ; returns ((S T) (U V) (W X))