Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

caaar ... caddr


Type:   -   function (subr)
Source:   -   xllist.c

Syntax

(caaar expr)
(caadr expr)
(cadar expr)
(caddr expr)
expr - a list expression
returns - the result of the last car function

Description

The 'caaar', 'caadr', 'cadar' and 'caddr' 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 'caddr' does a cdr on the expression, followed by a cdr, 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 'caddr' function returns the same result as the third function.

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))))

(caaar mylist)  => 11A
(caadr mylist)  => (21A 21B)
(cadar mylist)  => (12A 12B)
(caddr mylist)  => ((31A 31B) (32A 32B) (33A 33B))

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