diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | txr.1 | 18 |
3 files changed, 27 insertions, 0 deletions
@@ -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. @@ -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)); @@ -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 |