diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-07-30 08:11:02 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-07-30 08:11:02 -0700 |
commit | 147c1f0aad20859206c11c021d3ea065078941a4 (patch) | |
tree | 2bbe7c1956085599141847470bdbef7de04adc3f /lib.h | |
parent | 9e7cf279f3351b066d3a93402d6d43ef4c03f9bd (diff) | |
download | txr-147c1f0aad20859206c11c021d3ea065078941a4.tar.gz txr-147c1f0aad20859206c11c021d3ea065078941a4.tar.bz2 txr-147c1f0aad20859206c11c021d3ea065078941a4.zip |
keep-if, remove-if, keep-keys-if: mapfun argument.
We introduce a mapfun argument to these functions so that they
can additionally transform the accumulated values.
The keep-keys-if function is now implemented through the same
helper function as keep-if but with the mapfun argument
defaulting to a copy of the keyfun argument.
* eval.c (eval_init): Update registrations of remove-if,
keep-if and keep-keys-if to new arities of C functions.
* lib.c (rem_if_impl): Implement new optional mapfun
parameter.
(remove_if, keep_if): Add mapfun parameter.
(keep_keys_if): Implement via rem_if_impl, and add
mapfun argument. We do the defaulting of keyfun here,
so that we can then use that argument's value to default
mapfun.
* lib.h (remove_if, keep_if, keep_keys_if): Declarations
updated.
* tests/012/seq.tl: Couple of test cases exercising mapfun
argument of keep-if and remove-if.
* txr.1: Documented.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -889,12 +889,12 @@ val rmember_if(val pred, val list, val key); val remq(val obj, val seq, val keyfun); val remql(val obj, val seq, val keyfun); val remqual(val obj, val seq, val keyfun); -val remove_if(val pred, val seq, val keyfun); +val remove_if(val pred, val seq, val keyfun_in, val mapfun_in); val keepq(val obj, val seq, val keyfun); val keepql(val obj, val seq, val keyfun); val keepqual(val obj, val seq, val keyfun); -val keep_if(val pred, val seq, val keyfun); -val keep_keys_if(val pred, val seq_in, val keyfun_in); +val keep_if(val pred, val seq, val keyfun_in, val mapfun_in); +val keep_keys_if(val pred, val seq_in, val keyfun_in, val mapfun_in); val separate(val pred, val seq, val keyfun); val separate_keys(val pred, val seq_in, val keyfun_in); val remq_lazy(val obj, val list); |