From 5f9d1d22af102a8e9d2a769ea02243fb5763fe74 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 19 Jul 2014 13:04:33 -0700 Subject: * 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. --- ChangeLog | 7 +++++++ hash.c | 2 ++ txr.1 | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index f84751b4..d2a40266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-07-19 Kaz Kylheku + + * 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 * eval.c (mapdov): New function. 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 ) + +.TP +Description: + +The hash-construct function constructs a populated hash in one step. The +argument specifies a list suitable as an argument list in a call to the hash function. +The 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 ], then populated +with the specified pairs, and returned. + .SS Function hash-update .TP -- cgit v1.2.3