Description Usage Arguments Details Value
These functions are accessors for various elements and subsequences of lists and vectors. They are written in a type-generic way and will work for any broadly defined sequence type: vectors, lists (aka "generic vectors") and pairlists.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
x |
The object whose elements or subsequences to access. |
Using "sequence" to mean list, other vector or pairlist, the basic functions here are
car, which returns the first element of a sequence (car(x) is equivalent to x[[1]] for (pair)lists and to x[1] for vectors)
cdr, which returns the sequence consisting of every element but the first, or NULL for a sequence of length 0 or length 1
last, which returns the last element of a sequence
first, which is an alias for car
There are also a large number of functions of the form cXXXXr, where there
are two, three or four "a"'s or "d"'s between the c and r. These functions
are compositions of car and cdr: to give one example, caadr(x)
is
equivalent to car(car(cdr(x))). All such functions with up to four letters
between the c and the r are pre-defined here.
A particular element or subsequence.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.