[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.7.2.3 List Constructors
This section describes the procedures for constructing new lists.
list
simply returns a list where the elements are the arguments,
cons*
is similar, but the last argument is stored in the cdr of
the last pair of the list.
- Scheme Procedure: list elem …
- C Function: scm_list_1 (elem1)
- C Function: scm_list_2 (elem1, elem2)
- C Function: scm_list_3 (elem1, elem2, elem3)
- C Function: scm_list_4 (elem1, elem2, elem3, elem4)
- C Function: scm_list_5 (elem1, elem2, elem3, elem4, elem5)
- C Function: scm_list_n (elem1, …, elemN,
SCM_UNDEFINED
) -
Return a new list containing elements elem ....
scm_list_n
takes a variable number of arguments, terminated by the specialSCM_UNDEFINED
. That finalSCM_UNDEFINED
is not included in the list. None of elem … can themselves beSCM_UNDEFINED
, orscm_list_n
will terminate at that point.
- Scheme Procedure: cons* arg1 arg2 …
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 calledlist*
in some other Schemes and in Common LISP.
- Scheme Procedure: list-copy lst
- C Function: scm_list_copy (lst)
Return a (newly-created) copy of lst.
- Scheme Procedure: make-list n [init]
Create a list containing of n elements, where each element is initialized to init. init defaults to the empty list
()
if not given.
Note that list-copy
only makes a copy of the pairs which make up
the spine of the lists. The list elements are not copied, which means
that modifying the elements of the new list also modifies the elements
of the old list. On the other hand, applying procedures like
set-cdr!
or delv!
to the new list will not alter the old
list. If you also need to copy the list elements (making a deep copy),
use the procedure copy-tree
(see section Copying Deep Structures).
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on April 20, 2013 using texi2html 5.0.