From 760c77bd3936f1c655fb1886eb312aa6e9d89d9c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 16 Apr 2022 09:00:18 -0700 Subject: cons: mapcar, mappend: doc, tests. --- testcases-cons | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'testcases-cons') 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 +#include + +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 +#include + +function cs(x) { + return cox(x) +} + +BEGIN { + print sexp(mappend(fun(cs), list(0.2, 0.2, 0.3))) +}' +: +ERR -- cgit v1.2.3