summaryrefslogtreecommitdiffstats
path: root/tests/012
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-18 06:15:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-18 06:15:49 -0700
commit1fcd2951cbca8b1a72b0a7665032859139f03d10 (patch)
tree12e4d72a84f2f32495bd0a0e1790ebe1d92e52cb /tests/012
parent980942732a366f2042eac777b2d1e259a19d3652 (diff)
downloadtxr-1fcd2951cbca8b1a72b0a7665032859139f03d10.tar.gz
txr-1fcd2951cbca8b1a72b0a7665032859139f03d10.tar.bz2
txr-1fcd2951cbca8b1a72b0a7665032859139f03d10.zip
New function: count.
The general count function, with keyfun and testfun, is noticeably absent. Let's implement it. * lib.[ch] (count): New function. * eval.c (eval_init): Register count intrinsic. * tests/012/seq.tl: Some tests for count. * txr.1: Add count to count-if section. Revise documentation based on pos/pos-if. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/012')
-rw-r--r--tests/012/seq.tl10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl
index ae42a13e..71bdf5fd 100644
--- a/tests/012/seq.tl
+++ b/tests/012/seq.tl
@@ -489,3 +489,13 @@
[partition-if fn "a13cd9foo42z" 2] ("a13" "cd9" "foo42z")
[partition-if fn "a13cd9foo42z" 1] ("a13" "cd9foo42z")
[partition-if fn "a13cd9foo42z" 0] ("a13cd9foo42z"))
+
+(mtest
+ [count 1 nil] 0
+ [count 1 '(1 2 3 4 1 5)] 2
+ [count "abc" '("foo" "bar" "ABC" "abc" "def" "abc")] 2
+ [count "ABC" '("foo" "bar" "ABC" "abc" "def" "abc") : upcase-str] 3)
+
+(compile-only
+ (test
+ [count #1="abc" '("abc" "abc" "abc" #1# "abc" #1#" abc") eq] 2))