Node:List Selection, Next:, Previous:List Constructors, Up:Lists

22.2.4 List Selection

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

length lst Scheme Procedure
scm_length (lst) C Function
Return the number of elements in list lst.

last-pair lst Scheme Procedure
scm_last_pair (lst) C Function
Return a pointer to the last pair in lst, signalling an error if lst is circular.

list-ref list k Scheme Procedure
scm_list_ref (list, k) C Function
Return the kth element from list.

list-tail lst k Scheme Procedure
list-cdr-ref lst k Scheme Procedure
scm_list_tail (lst, k) C Function
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.

list-head lst k Scheme Procedure
scm_list_head (lst, k) C Function
Copy the first k elements from lst into a new list, and return it.