From 4571c3cb409808942ecbe353b1ffa6794cabc557 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Mon, 1 Jul 2024 20:07:38 +0100 Subject: add map test --- tests/map.bth | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/map.bth (limited to 'tests/map.bth') diff --git a/tests/map.bth b/tests/map.bth new file mode 100644 index 0000000..aa9f45e --- /dev/null +++ b/tests/map.bth @@ -0,0 +1,15 @@ +(set map' (fn (f ix in out) + (if (< ix (len in)) + (let (elem (in ix) + felem (f elem) + newix (+ 1 ix)) + (set (out ix) felem) + (map' f newix in out)) + out))) +(set map (fn (f in) (map' f 0 in (arr)))) + +(let (a [1 2 3 4 5 6 7 8 9] + f1 (fn (x) (* 10 x)) + f2 (fn (x) (* x x))) + (say (map f1 a)) + (say (map f2 a))) -- cgit v1.2.3