- fxmapping-unfold stop? mapper successor seed₁ seed₂ …procedure
The arguments have the following types:
- stop? : * * … → *-or-false
- mapper : * * … → fixnum *
- successor : * * … → * * …
- seed₁, seed₂, … : *
The stop?, mapper, and successor procedures must accept as many arguments as there are seed parameters. In addition, the number of values returned by the successor procedure must agree with the number of arguments expected by mapper; that is, the expression
(call-with-values (lambda () (successor seed₁ seed₂ … )) mapper)
must result in a valid procedure application.
Unfold a fxmapping from the initial seeds. mapper is applied to the seeds and returns two values, a key and an associated value, which are adjoined to the new fxmapping. successor maps the seeds to new seeds. Unfolding terminates when the predicate stop? returns a true value when applied to the current seeds. The resulting fxmapping is newly allocated.
It is an error for the number of seeds to vary between steps of the unfolding process. If different steps of this process produce associations with the same key, then the first such association takes precedence.
(fxmapping->alist (fxmapping-unfold (lambda (i) (= i 4)) (lambda (i) (values i (make-string i #\a))) (lambda (i) (+ i 1)) 0)) ⇒ ((0 . "") (1 . "a") (2 . "aa") (3 . "aaa"))