summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.c1
-rw-r--r--lib.c5
-rw-r--r--lib.h1
-rw-r--r--txr.117
4 files changed, 23 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index dd2adcf4..805805b3 100644
--- a/eval.c
+++ b/eval.c
@@ -6892,6 +6892,7 @@ void eval_init(void)
reg_fun(intern(lit("update"), user_package), func_n2(update));
reg_fun(intern(lit("search"), user_package), func_n4o(search, 2));
reg_fun(intern(lit("rsearch"), user_package), func_n4o(rsearch, 2));
+ reg_fun(intern(lit("contains"), user_package), func_n4o(contains, 2));
reg_fun(intern(lit("where"), user_package), func_n2(where));
reg_fun(intern(lit("select"), user_package), func_n2(sel));
reg_fun(intern(lit("relate"), user_package), func_n3o(relate, 2));
diff --git a/lib.c b/lib.c
index 3dce3750..acf66f36 100644
--- a/lib.c
+++ b/lib.c
@@ -10786,6 +10786,11 @@ val search(val seq, val key, val testfun, val keyfun)
}
}
+val contains(val key, val seq, val testfun, val keyfun)
+{
+ return search(seq, key, testfun, keyfun);
+}
+
static val rsearch_list(val seq, val key, val testfun, val keyfun)
{
val siter, kiter;
diff --git a/lib.h b/lib.h
index 6c5b17ef..115b11d2 100644
--- a/lib.h
+++ b/lib.h
@@ -1155,6 +1155,7 @@ val butlast(val seq, val idx);
val replace(val seq, val items, val from, val to);
val update(val seq, val fun);
val search(val seq, val key, val from, val to);
+val contains(val key, val seq, val testfun, val keyfun);
val rsearch(val seq, val key, val from, val to);
val where(val func, val seq);
val sel(val seq, val where);
diff --git a/txr.1 b/txr.1
index f0b1726d..0d087525 100644
--- a/txr.1
+++ b/txr.1
@@ -29680,7 +29680,7 @@ is returned.
.coNP Function @ search
.synb
-.mets (search < haystack < needle >> [ testfun <> [ keyfun ])
+.mets (search < haystack < needle >> [ testfun <> [ keyfun ]])
.syne
.desc
The
@@ -29773,6 +29773,21 @@ with one argument. If it is not supplied, it defaults to
[search "abcd" #(#\eC #\eD) : chr-toupper] -> 2
.brev
+.coNP Function @ contains
+.synb
+.mets (contains < needle < haystack >> [ testfun <> [ keyfun ]])
+.syne
+.desc
+The syntax of the
+.code contains
+function differs from that of
+.codn search :
+that the
+.meta needle
+and
+.meta haystack
+arguments are reversed. The semantics is identical.
+
.coNP Function @ rsearch
.synb
.mets (rsearch < haystack < needle >> [ testfun <> [ keyfun ])