diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-12 20:25:27 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-14 15:53:43 -0800 |
commit | 260968beacb1a2e1c6bdd652f75fe087f907ce0f (patch) | |
tree | 6f9da93f5136fc15dc0ad4c8fd1998edb8888081 /txr.1 | |
parent | ed290d6d0df5f4c694459f853983ab79929ea786 (diff) | |
download | txr-260968beacb1a2e1c6bdd652f75fe087f907ce0f.tar.gz txr-260968beacb1a2e1c6bdd652f75fe087f907ce0f.tar.bz2 txr-260968beacb1a2e1c6bdd652f75fe087f907ce0f.zip |
* eval.c (eval_init): Register hash_guni and hash_gisec as intrinsics.
* hash.c (hash_guni, hash_gisec): New functions.
(hash_isec): Bugfix: since gethash was naively used, keys in hash2
associated with the value nil were erroneously omitted from the
intersection.
* hash.h (hash_guni, hash_gisec): Declared.
* txr.1: Documented new functions.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -10594,14 +10594,16 @@ The <result-form> and <body-form>-s are in the scope of an implicit anonymous block, which means that it is possible to terminate the execution of dohash early using (return) or (return <value>). -.SS Functions hash-uni, hash-diff and hash-isec +.SS Functions hash-uni, hash-guni, hash-diff, hash-isec and hash-gisec .TP Syntax: (hash-uni <hash1> <hash2>) + (hash-guni <hash1> <hash2>) (hash-diff <hash1> <hash2>) (hash-isec <hash1> <hash2>) + (hash-gisec <hash1> <hash2>) .TP Description: @@ -10616,10 +10618,16 @@ make-similar-hash operation. If <hash1> has userdata, the resulting hash table has the same userdata. If <hash1> has weak keys, the resulting table has weak keys, and so forth. -The hash-uni function performs a set union. The resulting hash contains all of the -keys from <hash1> and all of the keys from <hash2>, and their corresponding values. -If a key occurs both in <hash1> and <hash2>, then it occurs only once in the -resulting hash. The value for this common key is the one from <hash2>. +The hash-uni function performs a set union. The resulting hash contains all of +the keys from <hash1> and all of the keys from <hash2>, and their corresponding +values. If a key occurs both in <hash1> and <hash2>, then it occurs only once +in the resulting hash. The value for this common key is the one from <hash2>. +The hash-guni function is similar, except that if a key occurs in both <hash1> +and <hash2>, then the respective data items from <hash1> and <hash2> for that +key appear appended together in the resulting hash as if by the append +function, in that order. (The hash-guni name is a reference to the group-by +function. A sequence of data items can be grouped in multiple ways, and then +the hashes combined with hash-guni.) The hash-diff function performs a set difference. First, a copy of <hash1> is made as if by the copy-has function. Then from this copy, all keys which occur @@ -10629,6 +10637,11 @@ The hash-isec function performs a set intersection. The resulting hash contains only those keys which occur both in <hash1> and <hash2>. The values selected for these common keys are those from <hash1>. +The hash-gisec function performs a set intersection similarly to hash-isec. +However, for each key placed in the resulting hash, the associated data is +formed by appending together the data item from <hash1> and from <hash2>, in +that order. + .SH PARTIAL EVALUATION AND COMBINATORS .SS Operators op and do |