aboutsummaryrefslogtreecommitdiffstats
path: root/testcases-cons
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-16 09:00:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-16 09:00:18 -0700
commit760c77bd3936f1c655fb1886eb312aa6e9d89d9c (patch)
treee3d47d645e614b4f7fbfecf4bb1a2cfc1069a9fc /testcases-cons
parentab705c920ca68471f7664181feee534220fe40c4 (diff)
downloadcppawk-760c77bd3936f1c655fb1886eb312aa6e9d89d9c.tar.gz
cppawk-760c77bd3936f1c655fb1886eb312aa6e9d89d9c.tar.bz2
cppawk-760c77bd3936f1c655fb1886eb312aa6e9d89d9c.zip
cons: mapcar, mappend: doc, tests.
Diffstat (limited to 'testcases-cons')
-rw-r--r--testcases-cons38
1 files changed, 38 insertions, 0 deletions
diff --git a/testcases-cons b/testcases-cons
index 0e0b2db..7b66766 100644
--- a/testcases-cons
+++ b/testcases-cons
@@ -703,3 +703,41 @@ nil
("abc" "abc")
("abc")
((1 . 2) (3 . 4) (3 . 5))
+--
+37:
+$cppawk '
+#include <cons.h>
+#include <fun.h>
+
+function sq (x) {
+ return sqrt(x)
+}
+
+BEGIN {
+ print sexp(mapcar(fun(42), nil))
+ print sexp(mapcar(bind(cons, "x"), list(1, 2, 3)))
+ print sexp(mappend(fun(42), nil))
+ print sexp(mappend(bind(list, "x"), list(1, 2, 3)))
+ print sexp(mapcar(fun(sq), list(0, 1, 4, 9, 16, 25)))
+}'
+:
+nil
+(("x" . 1) ("x" . 2) ("x" . 3))
+nil
+("x" 1 "x" 2 "x" 3)
+(0 1 2 3 4 5)
+--
+38:
+$cppawk '
+#include <cons.h>
+#include <fun.h>
+
+function cs(x) {
+ return cox(x)
+}
+
+BEGIN {
+ print sexp(mappend(fun(cs), list(0.2, 0.2, 0.3)))
+}'
+:
+ERR