summaryrefslogtreecommitdiff
path: root/tests/map.bth
blob: c3170bd77788b6dda28732b92a8bb4f8f3e6aa68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(set! map' (fn (f ix in out)
              (if (< ix (# 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)))