[ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

### 6.4.4 List accessors and modifiers

Function: car pair
Function: cdr pair
[R5RS] Returns car and cdr of pair, respectively.

Function: set-car! pair obj
Function: set-cdr! pair obj
[R5RS] Modifies car and cdr of pair, by obj, respectively.

Note: `(setter car)` == `set-car!`, and `(setter cdr)` == `set-cdr!`.

Function: caar pair
...
Function: cdddar pair
Function: cddddr pair
[R5RS] `caar` == `(car (car x))`, `cadr` == `(car (cdr x))`, and so on.

The corresponding setters are also defined.
 ```(let ((x (list 1 2 3 4 5))) (set! (caddr x) -1) x) => (1 2 -1 4 5) ```

Function: length list
[R5RS] Returns the length of a proper list list. If list is a dotted list, an error is signalled. If list is a circular list, this function diverges.

If you want to handle circular lists as well, See `length+` in 10.2.4 List miscellaneous routines.

Function: list-tail list k
[R5RS] Returns k-th cdr of list. list can be a proper, dotted or circular list.

Function: list-ref list k &optional fallback
[R5RS+] Returns k-th element of list. list can be a proper, dotted or circular list.

By default, `list-ref` signals an error if k is negative, or greater than or equal to the length of list. However, if an optional argument fallback is given, it is returned for such case. This is an extension of Gauche.

Function: last-pair list
[SRFI-1] Returns the last pair of list. list can be a proper or dotted list.

 [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html