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.

cdar cddr

cdar cddr

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

SYNTAX

(cdar <expr> )
(cddr <expr> )
        <expr>          -       a list or list expression

DESCRIPTION

The CDAR and CDDR 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 CDAR does a CAR on the expression, followed by a CDR. 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 '( (a1 a2)                 ; make a 2-level list
                (b1 b2) 
                (c1 c2) 
                (d1 d2) ) )
(cdar mylist)                           ; returns (A2)
(cddr mylist)                           ; returns ((C1 C2) (D1 D2))
(caar mylist)                           ; returns A1
(cadr mylist)                           ; returns (B1 B2)
(caar 'a)                               ; error: bad argument
(caar nil)                              ; returns NIL
(cadr nil)                              ; returns NIL
(cdar nil)                              ; returns NIL
(cddr nil)                              ; returns NIL


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