3.10 Mutable Pairs and Lists
A mutable pair is like a pair created by cons, but
it supports set-mcar! and set-mcdr! mutation
operations to change the parts of the mutable pair (like traditional Lisp and
Scheme pairs).
A mutable list is analogous to a list created with pairs, but
instead created with mutable pairs.
A mutable pair is not a pair; they are completely
separate datatypes. Similarly, a mutable list is not a
list, except that the empty list is also the empty mutable
list. Instead of programming with mutable pairs and mutable lists,
data structures such as pairs, lists, and hash tables are practically
always better choices.
A mutable list can be used as a single-valued sequence (see
Sequences). The elements of the mutable list serve as elements
of the sequence. See also in-mlist.
3.10.1 Mutable Pair Constructors and Selectors
Returns a newly allocated
mutable pair whose first
element is
a and second element is
d.
3.10.2 Mutable List Functions
For functions described in this section, contracts are not directly
enforced. In particular, when a mutable list is expected,
supplying any other kind of value (or mutating a value that starts as
a mutable list) tends to produce an exception from
mcar or mcdr.
Returns a newly allocated
mutable list containing the
vs as its elements.
Returns a newly allocated
mutable list with the same elements as
lst.
Returns a newly allocated
mutable list with the same elements as
mlst.
Returns the number of elements in mlst.
The
mappend! procedure appends the given
mutable lists by mutating
the tail of each to refer to the next, using
set-mcdr!. Empty
lists are dropped; in particular, the result of calling
mappend! with one or more empty lists is the same as the
result of the call with the empty lists removed from the set of
arguments.
Returns a procedure that returns
#t when given a
mutable list
for which
pred returns a true value for all elements.