Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference
caar, cadr
Type: |
- |
function (subr) |
Source: |
- |
xllist.c |
Syntax
- (caar expr)
(cadr expr)
- expr - a list expression
returns - the result of the last car function
Description
The 'caar' and 'cadr' 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 'cadr' does a
cdr on the expression, followed by a
car. 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
The 'cadr' function returns the same result as the
second function.
Examples
(setq mylist '((1A 1B) (2A 2B) (3A 3B)))
(caar mylist) => 1A
(cadr mylist) => (2A 2B)
(caar 'a) => error: bad argument
(caar 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