diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-09 06:25:11 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-09 06:25:11 -0800 |
commit | c2032024f5e5121dba9a629f5e6a182ca5d45f16 (patch) | |
tree | bcc2195735027e7133ee91249d349dc9be15584c /eval.c | |
parent | cd4d38de19b8ec286c70992bdda1c85f265b9a07 (diff) | |
download | txr-c2032024f5e5121dba9a629f5e6a182ca5d45f16.tar.gz txr-c2032024f5e5121dba9a629f5e6a182ca5d45f16.tar.bz2 txr-c2032024f5e5121dba9a629f5e6a182ca5d45f16.zip |
New function: cons-find.
* eval.c (cons_find): Static function removed; a new one is
implemented in lib.c.
(eval_init): Register cons-find intrinsic.
* lib.c (cons_find_rec): New static function.
(cons_find): New function.
* lib.h (cons_find): Declared.
* tests/012/cons.tl: New file.
* txr.1: Documented cons-find together with tree-find.
Document that tree-find's test-fun argument is optional,
defaulting to equal.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 1 insertions, 12 deletions
@@ -4142,18 +4142,6 @@ static val transform_op(val forms, val syms, val rg) } } -static val cons_find(val obj, val structure, val test) -{ - uses_or2; - - if (funcall2(test, obj, structure)) - return structure; - if (atom(structure)) - return nil; - return or2(cons_find(obj, car(structure), test), - cons_find(obj, cdr(structure), test)); -} - static val supplement_op_syms(val ssyms) { list_collect_decl (outsyms, tl); @@ -7370,6 +7358,7 @@ void eval_init(void) reg_fun(intern(lit("remove-if*"), user_package), func_n3o(remove_if_lazy, 2)); reg_fun(intern(lit("keep-if*"), user_package), func_n3o(keep_if_lazy, 2)); reg_fun(intern(lit("tree-find"), user_package), func_n3o(tree_find, 2)); + reg_fun(intern(lit("cons-find"), user_package), func_n3o(cons_find, 2)); reg_fun(intern(lit("countqual"), user_package), func_n2(countqual)); reg_fun(intern(lit("countql"), user_package), func_n2(countql)); reg_fun(intern(lit("countq"), user_package), func_n2(countq)); |