Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

caaar caadr cadar caddr

caaar caadr cadar caddr

type: function (subr) 
location: built-in
source file: xllist.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

(caaar <expr> )
(caadr <expr> )
(cadar <expr> )
(caddr <expr> )
        <expr>          -       a list or list expression

DESCRIPTION

The CAAAR, CAADR, CADAR and CADDR 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 CADDR does a CDR on the expression, followed by a CDR, followed by a CAR. If at any point the list is NIL, NIL is returned. If at any point a CAR operation is performed on an atom (as opposed to a list) an error is reported - "error: BAD ARGUMENT".

EXAMPLES

(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) )
                ) )
(caaar mylist)                          ; returns A
(caadr mylist)                          ; returns (G H)
(cadar mylist)                          ; returns (C D)
(caddr mylist)                          ; returns ((M N) (O P) (Q R))
(cdaar mylist)                          ; returns (B)
(cdadr mylist)                          ; returns ((I J) (K L))
(cddar mylist)                          ; returns ((E F))
(cdddr mylist)                          ; returns (((S T) (U V) (W X)))


Go to the first, previous, next, last section, table of contents.