summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-02-09 06:25:11 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-02-09 06:25:11 -0800
commit3fb108272f762a4e3afa3f2f925db03b3128c272 (patch)
treebcc2195735027e7133ee91249d349dc9be15584c /txr.1
parent25bf01699c2af7f8007404d5a62aeb1d64aee7b0 (diff)
downloadtxr-3fb108272f762a4e3afa3f2f925db03b3128c272.tar.gz
txr-3fb108272f762a4e3afa3f2f925db03b3128c272.tar.bz2
txr-3fb108272f762a4e3afa3f2f925db03b3128c272.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 'txr.1')
-rw-r--r--txr.148
1 files changed, 38 insertions, 10 deletions
diff --git a/txr.1 b/txr.1
index 3d02e35d..818e4155 100644
--- a/txr.1
+++ b/txr.1
@@ -23313,14 +23313,17 @@ infinite lazy structure.
--> (a b c d e f g nil z nil h)
.brev
-.coNP Function @ tree-find
+.coNP Functions @ tree-find and @ cons-find
.synb
-.mets (tree-find < obj < tree << test-function )
+.mets (tree-find < obj < tree <> [ test-function ])
+.mets (cons-find < obj < tree <> [ test-function ])
.syne
.desc
The
.code tree-find
-function searches
+and
+.code cons-find
+function search
.meta tree
for an occurrence of
.metn obj .
@@ -23338,9 +23341,14 @@ arguments, and has conventions similar to
.code eql
or
.codn equal .
+If an argument is omitted, the default function is
+.codn equal .
+Under both
.code tree-find
-works as follows. If
+and
+.codn cons-find ,
+if
.meta tree
is equivalent to
.meta obj
@@ -23348,13 +23356,17 @@ under
.metn test-function ,
then
.code t
-is returned to announce a successful finding.
-If this test fails, and
-.meta tree
-is an atom,
+is returned to announce a successful finding. Next, if the mismatched
+.meta obj
+is an atom, both functions return
.code nil
-is returned immediately to
-indicate that the find failed. Otherwise,
+to indicate that the search failed.
+
+If none of the above cases occur, the semantics of the functions diverge, as
+follows.
+
+In the case of
+.codn tree-find ,
.meta tree
is taken to be a proper list,
and
@@ -23369,6 +23381,22 @@ which returns a
.cod2 non- nil
value.
+In the case of
+.codn cons-find ,
+.meta tree
+is taken to be
+.codn cons -cell-based
+tree structure. The
+.code cons-find
+function is recursively applied to the
+.code car
+and
+.code cdr
+fields of
+.metn tree .
+Thus a match may be found in any position in the structure, including the
+dotted position of a list.
+
.coNP Functions @, memq @ memql and @ memqual
.synb
.mets (memq < object << list )