Add `vhash-fold-right'.
* module/ice-9/vlist.scm (vhash-fold-right): New procedure.
* test-suite/tests/vlist.test ("vhash")["vhash-fold-right"]: New test.
* doc/ref/api-compound.texi (VHashes): Document `vhash-fold-right'.
This commit is contained in:
parent
bc00e06c7e
commit
19301dc56d
3 changed files with 23 additions and 5 deletions
|
|
@ -33,7 +33,7 @@
|
|||
vhash? vhash-cons vhash-consq vhash-consv
|
||||
vhash-assoc vhash-assq vhash-assv
|
||||
vhash-delete vhash-delq vhash-delv
|
||||
vhash-fold
|
||||
vhash-fold vhash-fold-right
|
||||
vhash-fold* vhash-foldq* vhash-foldv*
|
||||
alist->vhash))
|
||||
|
||||
|
|
@ -560,6 +560,16 @@ with @var{equal?}."
|
|||
seed
|
||||
vhash))
|
||||
|
||||
(define (vhash-fold-right proc seed vhash)
|
||||
"Fold over the key/pair elements of @var{vhash}, starting from the 0th
|
||||
element. For each pair call @var{proc} as @code{(@var{proc} key value
|
||||
result)}."
|
||||
(vlist-fold-right (lambda (key+value result)
|
||||
(proc (car key+value) (cdr key+value)
|
||||
result))
|
||||
seed
|
||||
vhash))
|
||||
|
||||
(define* (alist->vhash alist #:optional (hash hash))
|
||||
"Return the vhash corresponding to @var{alist}, an association list."
|
||||
(fold-right (lambda (pair result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue