diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-12 22:09:48 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-14 15:53:43 -0800 |
commit | b21d9c695dfb570a459129885063749e6efa561e (patch) | |
tree | c87a1f73d359c574e9d99591660e20af762413c0 /eval.c | |
parent | 260968beacb1a2e1c6bdd652f75fe087f907ce0f (diff) | |
download | txr-b21d9c695dfb570a459129885063749e6efa561e.tar.gz txr-b21d9c695dfb570a459129885063749e6efa561e.tar.bz2 txr-b21d9c695dfb570a459129885063749e6efa561e.zip |
Different approach: optional arguments on hash-isec and hash-uni allow
for more flexible joining of data from the hash tables.
* eval.c (eval_init): Remove hash_guni and hash_gisec. Change
registration for hash_uni and hash_isec to three arguments with
one optional.
* hash.c (hash_uni): Third parameter introduced, join_func.
The default behavior changes: in the two argument case,
clashing keys prefer the value from hash1 rather than hash2.
For this reason, we now iterate over hash2 first, then hash1.
(hash_guni): Removed.
(hash_isec): Third parameter introduced, join_func.
(hash_gisec): Removed.
* hash.h (hash_uni, hash_isec): Declarations updated.
(hash_guni, hash_gisec): Delarations removed.
* txr.1: Documentation updated.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -2508,11 +2508,9 @@ void eval_init(void) reg_fun(intern(lit("hash-values"), user_package), func_n1(hash_values)); reg_fun(intern(lit("hash-pairs"), user_package), func_n1(hash_pairs)); reg_fun(intern(lit("hash-alist"), user_package), func_n1(hash_alist)); - reg_fun(intern(lit("hash-uni"), user_package), func_n2(hash_uni)); - reg_fun(intern(lit("hash-guni"), user_package), func_n2(hash_guni)); + reg_fun(intern(lit("hash-uni"), user_package), func_n3o(hash_uni, 2)); reg_fun(intern(lit("hash-diff"), user_package), func_n2(hash_diff)); - reg_fun(intern(lit("hash-isec"), user_package), func_n2(hash_isec)); - reg_fun(intern(lit("hash-gisec"), user_package), func_n2(hash_gisec)); + reg_fun(intern(lit("hash-isec"), user_package), func_n3o(hash_isec, 2)); reg_fun(intern(lit("group-by"), user_package), func_n2v(group_by)); reg_fun(intern(lit("hash-update"), user_package), func_n2(hash_update)); |