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 /tests/012 | |
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 'tests/012')
-rw-r--r-- | tests/012/seq.tl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl index 148f1899..5d63fbf5 100644 --- a/tests/012/seq.tl +++ b/tests/012/seq.tl @@ -1617,3 +1617,7 @@ (seq-like "" #\a #\b 3) (#\a #\b 3) (seq-like #() 1 2 3) #(1 2 3) (seq-like #b'' 1 2 3) #b'010203') + +(mtest + [keep-if (lop find "aiueo") "vertebrate" : chr-toupper] "EEAE" + [remove-if (lop find "aiueo") "vertebrate" : chr-toupper] "VRTBRT") |