mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 18:20:22 +02:00
Fix documentation for vhash-fold and vhash-fold-right
* doc/ref/api-compound.texi (VHashes): Add missing `init' parameter in documentation for vhash-fold and vhash-fold-right, and also improve description. * module/ice-9/vlist.scm (vhash-fold, vhash-fold-right): Rename formal parameter `seed' to `init', to match documentation. Improve docstrings.
This commit is contained in:
parent
3004fe2624
commit
2f50d0a897
2 changed files with 19 additions and 13 deletions
|
@ -545,23 +545,26 @@ with @var{equal?}."
|
|||
(define vhash-delq (cut vhash-delete <> <> eq? hashq))
|
||||
(define vhash-delv (cut vhash-delete <> <> eqv? hashv))
|
||||
|
||||
(define (vhash-fold proc seed vhash)
|
||||
"Fold over the key/pair elements of @var{vhash}. For each pair call
|
||||
@var{proc} as @code{(@var{proc} key value result)}."
|
||||
(define (vhash-fold proc init vhash)
|
||||
"Fold over the key/pair elements of @var{vhash} from left to right, with
|
||||
each call to @var{proc} having the form @code{(@var{proc} key value result)},
|
||||
where @var{result} is the result of the previous call to @var{proc} and
|
||||
@var{init} the value of @var{result} for the first call to @var{proc}."
|
||||
(vlist-fold (lambda (key+value result)
|
||||
(proc (car key+value) (cdr key+value)
|
||||
result))
|
||||
seed
|
||||
init
|
||||
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)}."
|
||||
(define (vhash-fold-right proc init vhash)
|
||||
"Fold over the key/pair elements of @var{vhash} from right to left, with
|
||||
each call to @var{proc} having the form @code{(@var{proc} key value result)},
|
||||
where @var{result} is the result of the previous call to @var{proc} and
|
||||
@var{init} the value of @var{result} for the first call to @var{proc}."
|
||||
(vlist-fold-right (lambda (key+value result)
|
||||
(proc (car key+value) (cdr key+value)
|
||||
result))
|
||||
seed
|
||||
init
|
||||
vhash))
|
||||
|
||||
(define* (alist->vhash alist #:optional (hash hash))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue