Next: Substitution of Expressions, Up: Lists
This section describes a number of simple operations on lists, i.e., chains of cons cells.
This function is equivalent to
(car (cdr (cdr
x)))
. Likewise, this package defines all 24c
xxxr
functions where xxx is up to four ‘a’s and/or ‘d’s. All of these functions aresetf
-able, and calls to them are expanded inline by the byte-compiler for maximum efficiency.
This function is a synonym for
(car
x)
. Likewise, the functionscl-second
,cl-third
, ..., throughcl-tenth
return the given element of the list x.
This function acts like
null
, but signals an error ifx
is neither anil
nor a cons cell.
This function returns the length of list x, exactly like
(length
x)
, except that if x is a circular list (where the cdr-chain forms a loop rather than terminating withnil
), this function returnsnil
. (The regularlength
function would get stuck if given a circular list. See also thesafe-length
function.)
This function constructs a list of its arguments. The final argument becomes the cdr of the last cell constructed. Thus,
(cl-list*
a b c)
is equivalent to(cons
a(cons
b c))
, and(cl-list*
a bnil)
is equivalent to(list
a b)
.
If sublist is a sublist of list, i.e., is
eq
to one of the cons cells of list, then this function returns a copy of the part of list up to but not including sublist. For example,(cl-ldiff x (cddr x))
returns the first two elements of the listx
. The result is a copy; the original list is not modified. If sublist is not a sublist of list, a copy of the entire list is returned.
This function returns a copy of the list list. It copies dotted lists like
(1 2 . 3)
correctly.
This function compares two trees of cons cells. If x and y are both cons cells, their cars and cdrs are compared recursively. If neither x nor y is a cons cell, they are compared by
eql
, or according to the specified test. The:key
function, if specified, is applied to the elements of both trees. See Sequences.