1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 04:15:36 +02:00

Add procedures to convert alists into hash tables.

* module/ice-9/hash-table.scm: New module.

* test-suite/tests/hash.test ("alist conversion"): Add tests.

* doc/ref/api-compound.texi (Hash Table Reference): Add docs.
This commit is contained in:
David Thompson 2013-10-19 22:43:37 -04:00 committed by Mark H Weaver
parent 02500d4477
commit 5063f0a93b
4 changed files with 104 additions and 1 deletions

View file

@ -3829,6 +3829,27 @@ then it can use @var{size} to avoid rehashing when initial entries are
added.
@end deffn
@deffn {Scheme Procedure} alist->hash-table alist
@deffnx {Scheme Procedure} alist->hashq-table alist
@deffnx {Scheme Procedure} alist->hashv-table alist
@deffnx {Scheme Procedure} alist->hashx-table hash assoc alist
Convert @var{alist} into a hash table. When keys are repeated in
@var{alist}, the leftmost association takes precedence.
@example
(use-modules (ice-9 hash-table))
(alist->hash-table '((foo . 1) (bar . 2)))
@end example
When converting to an extended hash table, custom @var{hash} and
@var{assoc} procedures must be provided.
@example
(alist->hashx-table hash assoc '((foo . 1) (bar . 2)))
@end example
@end deffn
@deffn {Scheme Procedure} hash-table? obj
@deffnx {C Function} scm_hash_table_p (obj)
Return @code{#t} if @var{obj} is a abstract hash table object.