4.11 Mutable Pairs and Lists (original) (raw)

4.11 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 alist, 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 (seeSequences). The elements of the mutable list serve as elements of the sequence. See also in-mlist.

4.11.1 Mutable Pair Constructors and Selectors🔗

Returns #t if v is a mutable pair, #f otherwise.

Returns a newly allocatedmutable pair whose first element is a and second element is d.

Returns the first element of themutable pair p.

Returns the second element of themutable pair p.

Changes the mutable pair p so that its first element isv.

Changes the mutable pair p so that its second element isv.