Nyquist / XLISP 2.0  - 
Contents |
Tutorials |
Examples |
Reference
cdar, cddr
  | Type: | - | function (subr) | 
  | Source: | - | xllist.c | 
Syntax
- (cdar expr)
 (cddr expr)
- expr - a list or list expression
 returns - the result of the last cdr
function
 
Description
The 'cdar' and 'cddr' functions go through the list expression and perform a
sequence of  car or
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, then NIL is returned.
If at any point a car operation is
performed on an atom [as opposed to a list] an error is signalled:
error: bad argument
Examples
(setq mylist '((1A 1B) (2A 2B) (3A 3B))) 
(caar mylist)  => 1A
(cadr mylist)  => (2A 2B)
(cdar mylist)  => (1B)
(cddr mylist)  => ((3A 3B))
(cdar 'a)      => error: bad argument
(cdar nil)     => NIL
Note: The 'c...r' functions are part of the
historical Lisp functions. You may find it easier to work with the modern
lisp functions like nth and
nthcdr.
See also:
  Back to Top
Nyquist / XLISP 2.0  - 
Contents |
Tutorials |
Examples |
Reference