summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--hash.c2
-rw-r--r--txr.118
3 files changed, 27 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f84751b4..d2a40266 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2014-07-19 Kaz Kylheku <kaz@kylheku.com>
+ * hash.c (hash_construct): Nullify the pairs argument so that
+ it works correctly with an empty vector.
+
+ * txr.1: Write missing documentation for hash-construct.
+
+2014-07-19 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (mapdov): New function.
(eval_init): Register mapdo intrinsic.
diff --git a/hash.c b/hash.c
index f4692d56..92a05191 100644
--- a/hash.c
+++ b/hash.c
@@ -812,6 +812,8 @@ val hash_construct(val hashv_args, val pairs)
{
val hash = hashv(hashv_args);
+ pairs = nullify(pairs);
+
for (; pairs; pairs = cdr(pairs)) {
val pair = car(pairs);
sethash(hash, first(pair), second(pair));
diff --git a/txr.1 b/txr.1
index 47ac3388..666d238c 100644
--- a/txr.1
+++ b/txr.1
@@ -11769,6 +11769,24 @@ the equal function instead.
In addition to storing key-value pairs, a hash table can have a piece of
information associated with it, called the user data.
+.SS Function hash-construct
+
+.TP
+Syntax:
+
+ (hash-construct <hash-args> <key-val-pairs>)
+
+.TP
+Description:
+
+The hash-construct function constructs a populated hash in one step. The <hash-args>
+argument specifies a list suitable as an argument list in a call to the hash function.
+The <key-val-pairs> is a sequence of pairs, which are two-element lists representing
+key-value pairs.
+
+A hash is constructed as if by a call to [apply hash <hash-args>], then populated
+with the specified pairs, and returned.
+
.SS Function hash-update
.TP