summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-10-19 22:43:37 -0400
committerMark H Weaver <mhw@netris.org>2013-11-18 23:03:38 -0500
commit5063f0a93bb4349ee527b6fd98ff50ea9fa0fe42 (patch)
treed3f37beef4a7b75f6a30f84bfeb5884364f46b4a /doc
parent02500d44775a77e46febfd47a0dab8233b0c99d0 (diff)
downloadguile-5063f0a93bb4349ee527b6fd98ff50ea9fa0fe42.tar.gz
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/ref/api-compound.texi21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi
index 94e01450e..0b14c4889 100644
--- a/doc/ref/api-compound.texi
+++ b/doc/ref/api-compound.texi
@@ -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.