|Version 4 (modified by cowan, 4 years ago) (diff)|
This library provides immutable pairs. Note that they are simply immutable and make no special provisions for functional update: there are no analogues of set-car! and set-cdr!. They are also unrelated to ordinary Scheme pairs.
From immutable pairs plus the empty list we can build immutable lists. Note that the empty list can be safely used in both mutable and immutable lists, because it itself is immutable.
- Should there be a lexical syntax for iquote, analogous to ' for quote? One possibility would be #i, which means "inexact" when used before a number, but nothing special when it precedes a literal list.
- In SRFI 1, length is R5RS length (which may loop on circular structure) and length+ is R6RS/R7RS-small length (which must not). Both have their uses, and whatever is done for R7RS-large should be done here too.
Returns a copy of <datum> with all pairs replaced by immutable pairs. Note that <datum> can be circular or have shared structure, which is preserved.
Returns a copy of obj with all pairs replaced by immutable pairs. Note that obj can be circular or have shared structure, which is preserved. If there are no pairs, the result may be the same as the argument.
Returns a copy of obj with all immutable pairs replaced by pairs. Note that obj can be circular or have shared structure, which is preserved. If there are no immutable pairs, the result may be the same as the argument.
The following procedures are renamed from those in SRFI 1. They are a superset of those in R5RS and R7RS-small. The intention is to make immutable lists as close to a drop-in replacement for ordinary lists as possible. Each one does exactly what you'd expect from reading SRFI 1.
icons ilist ixcons icons* make-ilist ilist-tabulate ilist-copy circular-ilist ilist-iota
ipair? ilist? proper-ilist? circular-ilist? dotted-ilist? null-ilist? ilist=
icar icdr ... icddadr icddddr ilist-ref icar+icdr ilist-take ilist-drop (also known as ilist-tail) ilist-take-right ilist-drop-right split-at ilist-last ilist-last-pair
ilist-length ilist-append ilist-concatenate ilist-reverse ilist-append-reverse ilist-zip ilist-unzip1 ilist-unzip2 ilist-unzip3 ilist-unzip4 ilist-unzip5 ilist-count
Fold, unfold & map:
ilist-map ilist-for-each ilist-fold ilist-unfold ilist-pair-fold ilist-reduce ilist-fold-right ilist-unfold-right ipair-fold-right ilist-reduce-right ilist-append-map ilist-pair-for-each ilist-filter-map ilist-map-in-order
Filtering & partitioning:
ilist-filter ilist-partition ilist-remove
ilist-member ilist-memq ilist-memv ilist-find ilist-find-tail ilist-any ilist-every ilist-index ilist-take-while ilist-drop-while ilist-span ilist-break
Immutable association lists:
ilist-assoc ilist-assq ilist-assv ialist-cons ialist-copy ialist-delete
Set operations on immutable lists:
ilist-set<= ilist-set= ilist-set-adjoin ilist-set-union ilist-set-intersection ilist-set-difference ilist-set-xor ilist-set-diff+intersection