Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference
cdaar ... cdddr
Type: |
- |
function (subr) |
Source: |
- |
xllist.c |
Syntax
- (cdaar expr)
(cdadr expr)
(cddar expr)
(cdddr expr)
- expr - a list or list expression
returns - the result of the last cdr
function
Description
The 'cdaar', 'cdadr', 'cddar' and 'cdddr' 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 'cddar' does a
car on the expression, followed by a
acdr, followed by another
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 '(((11A 11B) (12A 12B) (13A 13B))
((21A 21B) (22A 22B) (23A 23B))
((31A 31B) (32A 32B) (33A 33B))
((41A 41B) (42A 42B) (43A 43B))))
(cdaar mylist) => (11B)
(cdadr mylist) => ((22A 22B) (23A 23B))
(cddar mylist) => ((13A 13B))
(cdddr mylist) => (((41A 41B) (42A 42B) (43A 43B)))
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