From 5a1a9076e10d03a070daa0e8c019fc0ec76e5c88 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 24 Jun 2015 06:04:43 -0700 Subject: * hash.c (hash_from_pairs, hash_list): New functions. * hash.h (hash_from_pairs, hash_list): Declared. * eval.c (eval_init): Registered hash-from-pairs and hash-list intrinsic. * txr.1: Documented new functions. --- txr.1 | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 3a26ad89..c9501c22 100644 --- a/txr.1 +++ b/txr.1 @@ -21723,9 +21723,10 @@ is fully instantiated. In the meanwhile, the \*(TX program can mutate the hash table from which the lazy list is being generated. -.coNP Function @ hash-construct +.coNP Functions @ hash-construct and @ hash-from-pairs .synb .mets (hash-construct < hash-args << key-val-pairs ) +.mets (hash-from-pairs < key-val-pairs << hash-arg *) .syne .desc The @@ -21740,11 +21741,42 @@ lists representing key-value pairs. A hash is constructed as if by a call to .cblk -.meti [apply hash << hash-args ], +.meti (apply hash << hash-args ), .cble then populated with the specified pairs, and returned. +The +.code hash-from-pairs +function is an alternative interface to the same semantics. The +.meta key-val-pairs +argument is first, and the +.meta hash-args +are passed as trailing variadic arguments, rather than a single list argument. + +.coNP Function @ hash-list +.synb +.mets (hash-list < key-list << hash-arg *) +.syne +.desc +The +.code hash-list +function constructs a hash as if by a call to +.cblk +.meti (apply hash << hash-args ), +.cble +where +.meta hash-args +is a list of the individual +.meta hash-arg +variadic arguments. + +The hash is then populated with keys taken from +.meta key-list +and returned. + +The value associated with each key is that key itself. + .coNP Function @ hash-update .synb .mets (hash-update < hash << function ) -- cgit v1.2.3