6.6.9.4 List Selection

These procedures are used to get some information about a list, or to retrieve one or more elements of a list.

Scheme Procedure: length lst
C Function: scm_length (lst)

Return the number of elements in list lst.

Scheme Procedure: last-pair lst
C Function: scm_last_pair (lst)

Return the last pair in lst, signaling an error if lst is circular.

Scheme Procedure: list-ref list k
C Function: scm_list_ref (list, k)

Return the kth element from list.

Scheme Procedure: list-tail lst k
Scheme Procedure: list-cdr-ref lst k
C Function: scm_list_tail (lst, k)

Return the "tail" of lst beginning with its kth element. The first element of the list is considered to be element 0.

list-tail and list-cdr-ref are identical. It may help to think of list-cdr-ref as accessing the kth cdr of the list, or returning the results of cdring k times down lst.

Scheme Procedure: list-head lst k
C Function: scm_list_head (lst, k)

Copy the first k elements from lst into a new list, and return it.