summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-05-25 19:44:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-05-25 19:44:02 -0700
commit69fd1c3054df29be26299b4b23bac29e2c2bceb5 (patch)
treee3551fa2ce25ecb4e3c72f7d081731e5c181093d /txr.1
parent989f2de823ed6f8edd14540665e9ff1041ae79cc (diff)
downloadtxr-69fd1c3054df29be26299b4b23bac29e2c2bceb5.tar.gz
txr-69fd1c3054df29be26299b4b23bac29e2c2bceb5.tar.bz2
txr-69fd1c3054df29be26299b4b23bac29e2c2bceb5.zip
search, rsearch: rewrite using seq_info and bugfix.
* lib.c (seq_getpos, seq_setpos): New functions. * lib.h (seq_getpos, seq_setpos): Declared. (search_list, rsearch_list): Static functions removed. (search_common): New static function. (search, contains, rsearch): These functions are now trivial wrappers around search_common. A requirement problem is fixed in rsearch: when the key is empty, the length of sequence is returned rather than zero, because zero is obviously not the right most place where an empty key matches. * txr.1: Documentation updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.120
1 files changed, 16 insertions, 4 deletions
diff --git a/txr.1 b/txr.1
index 1afe9b7c..5b531ab5 100644
--- a/txr.1
+++ b/txr.1
@@ -29782,12 +29782,11 @@ The arguments
.meta haystack
and
.meta needle
-are sequences: lists, vectors
-or strings, in any combination.
+are sequences. They may not be hash tables.
If
.meta needle
-is not empty, then occurs at some position N within
+is not empty, then it occurs at some position N within
.meta haystack
if
the first element of
@@ -29865,7 +29864,9 @@ The
.code rsearch
function is like
.code search
-except that if
+except for two differences.
+
+Firstly, if
.meta needle
matches
.meta haystack
@@ -29874,6 +29875,17 @@ in multiple places,
returns the right-most matching position rather than
the leftmost.
+Secondly, if
+.meta needle
+is an empty sequence, then
+.code rsearch
+returns the length of
+.codn haystack ,
+thereby effectively declaring that the rightmost match for an empty
+.meta needle
+key occurs at the imaginary position past the element of
+.metn haystack .
+
.coNP Functions @ ref and @ refset
.synb
.mets (ref < seq << index )