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

### 10.2.3 List selectors

Function: first pair
Function: second pair
Function: third pair
Function: fourth pair
Function: fifth pair
Function: sixth pair
Function: seventh pair
Function: eighth pair
Function: ninth pair
Function: tenth pair
[SRFI-1] Returns n-th element of the (maybe improper) list.

Function: car+cdr pair
[SRFI-1] Returns two values, `(car pair)` and `(cdr pair)`.

Function: take x i
Function: drop x i
[SRFI-1] `take` returns the first i elements of list x. `drop` returns all but the first i elements of list x.
 ```(take '(a b c d e) 2) => (a b) (drop '(a b c d e) 2) => (c d e) ```
x may be any value:
 ```(take '(1 2 3 . d) 2) => (1 2) (drop '(1 2 3 . d) 2) => (3 . d) (drop '(1 2 3 . d) 3) => d ```
`drop` is exactly equivalent to performing i cdr operations on x. The returned value shares a common tail with x. On the other hand, take always allocates a new list for result if the argument is a list of non-zero length.

Function: take-right flist i
Function: drop-right flist i
[SRFI-1] `take-right` returns the last i elements of flist. `drop-right` returns all but the last i elements of flist.
 ```(take-right '(a b c d e) 2) => (d e) (drop-right '(a b c d e) 2) => (a b c) ```
flist may be any finite list.
 ```(take-right '(1 2 3 . d) 2) => (2 3 . d) (drop-right '(1 2 3 . d) 2) => (1) (take-right '(1 2 3 . d) 0) => d (drop-right '(1 2 3 . d) 0) => (1 2 3) ```
`take-right`'s return value always shares a common tail with flist. `drop-right` always allocates a new list if the argument is a list of non-zero length.

Function: take! x i
Function: drop-right! x i
[SRFI-1] Linear update variants of take and drop-right. Those procedures may destructively modifies x.

If x is circular, `take!` may return a list shorter than expected.

Function: split-at x i
Function: split-at! x i
[SRFI-1] `split-at` splits the list x at index i, returning a list of the first i elements, and the remaining tail.
 ```(split-at '(a b c d e) 2) => (a b) (c d e) ```
`split-at!` is the linear-update variant. It may destructively modifes x to produce the result.

Function: last pair
[SRFI-1] Returns the last element of the non-empty, finite list pair. It is equivalent to `(car (last-pair pair))`. Note that `last-pair` is Gauche built-in procedure.

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

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