Lists
=====
- primitive: list . objs
Return a list containing OBJS, the arguments to `list'.
- primitive: cons* arg . rest
Like `list', but the last arg provides the tail of the constructed
list, returning (cons ARG1 (cons ARG2 (cons ... ARGn))). Requires
at least one argument. If given one argument, that argument is
returned as result. This function is called `list*' in some other
Schemes and in Common LISP.
- primitive: list? x
Return #t iff X is a proper list, else #f.
- primitive: null? x
Return #t iff X is the empty list, else #f.
- primitive: length lst
Return the number of elements in list LST.
- primitive: append . args
Returns a list consisting of the elements of the first LIST
followed by the elements of the other LISTs.
(append '(x) '(y)) => (x y)
(append '(a) '(b c d)) => (a b c d)
(append '(a (b)) '((c))) => (a (b) (c))
The resulting list is always newly allocated, except that it shares
structure with the last LIST argument. The last argument may
actually be any object; an improper list results if the last
argument is not a proper list.
(append '(a b) '(c . d)) => (a b c . d)
(append '() 'a) => a
- primitive: append! . args
A destructive version of `append' (*note Pairs and Lists:
(r4rs)Pairs and Lists.). The cdr field of each list's final pair
is changed to point to the head of the next list, so no consing is
performed. Return a pointer to the mutated list.
- primitive: last-pair lst
Return a pointer to the last pair in LST, signalling an error if
LST is circular.
- primitive: reverse lst
Return a new list that contains the elements of LST but in reverse
order.
- primitive: reverse! lst [new_tail]
A destructive version of `reverse' (*note Pairs and Lists:
(r4rs)Pairs and Lists.). The cdr of each cell in LST is modified
to point to the previous list element. Return a pointer to the
head of the reversed list.
Caveat: because the list is modified in place, the tail of the
original list now becomes its head, and the head of the original
list now becomes the tail. Therefore, the LST symbol to which the
head of the original list was bound now points to the tail. To
ensure that the head of the modified list is not lost, it is wise
to save the return value of `reverse!'
- primitive: list-ref list k
Return the Kth element from LIST.
- primitive: list-set! list k val
Set the Kth element of LIST to VAL.
- primitive: list-tail lst k
- primitive: list-cdr-ref 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.
- primitive: list-cdr-set! list k val
Set the Kth cdr of LIST to VAL.
- primitive: list-head lst k
Copy the first K elements from LST into a new list, and return it.
- primitive: list-copy lst
Return a (newly-created) copy of LST.
- primitive: memq x lst
Return the first sublist of LST whose car is `eq?' to X where the
sublists of LST are the non-empty lists returned by `(list-tail
LST K)' for K less than the length of LST. If X does not occur in
LST, then `#f' (not the empty list) is returned.
- primitive: memv x lst
Return the first sublist of LST whose car is `eqv?' to X where the
sublists of LST are the non-empty lists returned by `(list-tail
LST K)' for K less than the length of LST. If X does not occur in
LST, then `#f' (not the empty list) is returned.
- primitive: member x lst
Return the first sublist of LST whose car is `equal?' to X where
the sublists of LST are the non-empty lists returned by
`(list-tail LST K)' for K less than the length of LST. If X does
not occur in LST, then `#f' (not the empty list) is returned.
- primitive: delq item lst
Return a newly-created copy of LST with elements `eq?' to ITEM
removed. This procedure mirrors `memq': `delq' compares elements
of LST against ITEM with `eq?'.
- primitive: delv item lst
Return a newly-created copy of LST with elements `eqv?' to ITEM
removed. This procedure mirrors `memv': `delv' compares elements
of LST against ITEM with `eqv?'.
- primitive: delete item lst
Return a newly-created copy of LST with elements `equal?' to ITEM
removed. This procedure mirrors `member': `delete' compares
elements of LST against ITEM with `equal?'.
- primitive: delq! item lst
- primitive: delv! item lst
- primitive: delete! item lst
These procedures are destructive versions of `delq', `delv' and
`delete': they modify the pointers in the existing LST rather than
creating a new list. Caveat evaluator: Like other destructive
list functions, these functions cannot modify the binding of LST,
and so cannot be used to delete the first element of LST
destructively.
- primitive: delq1! item lst
Like `delq!', but only deletes the first occurrence of ITEM from
LST. Tests for equality using `eq?'. See also `delv1!' and
`delete1!'.
- primitive: delv1! item lst
Like `delv!', but only deletes the first occurrence of ITEM from
LST. Tests for equality using `eqv?'. See also `delq1!' and
`delete1!'.
- primitive: delete1! item lst
Like `delete!', but only deletes the first occurrence of ITEM from
LST. Tests for equality using `equal?'. See also `delq1!' and
`delv1!'.
[FIXME: is there any reason to have the `sloppy' functions available at
high level at all? Maybe these docs should be relegated to a "Guile
Internals" node or something. -twp]
- primitive: sloppy-memq x lst
This procedure behaves like `memq', but does no type or error
checking. Its use is recommended only in writing Guile internals,
not for high-level Scheme programs.
- primitive: sloppy-memv x lst
This procedure behaves like `memv', but does no type or error
checking. Its use is recommended only in writing Guile internals,
not for high-level Scheme programs.
- primitive: sloppy-member x lst
This procedure behaves like `member', but does no type or error
checking. Its use is recommended only in writing Guile internals,
not for high-level Scheme programs.
- primitive: map proc arg1 . args
- primitive: map-in-order proc arg1 . args
- primitive: for-each proc arg1 . args