blob: 1bc7f056dbd9cd973ded448778d4f5c3b487443c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
(letrec (concatN : [Int] -> [Int] -> [Int] l1 : [Int] l2 : [Int])
(if (isnil l1)
l2
(let (h) (head l1)
(let (t) (tail l1)
(cons h (concatN t l2)))))
(letrec (concatMapN : (Int -> [Int]) -> [Int] -> [Int] f : (Int -> [Int]) l : [Int])
(if (isnil l)
(nil : [Int])
(let (h) (head l)
(let (t) (tail l)
(concatN (f h) (concatMapN f t)))))
(letrec (applyEachN : [Int -> Int] -> Int -> [Int] fs : [Int -> Int] n : Int)
(if (isnil fs)
nil : [Int]
(let (hf) (head fs)
(let (tfs) (tail fs)
(cons (hf n) (applyEachN tfs n)))))
(let (applyEachToEachN fs : [Int -> Int] l : [Int])
(concatMapN (applyEachN fs) l)
(let (fs) (cons (lambda n : Int (+ n 2))
(cons (lambda n : Int (* n 2)) nil : [Int -> Int]))
(let (list) (cons 1 (cons 2 (cons 3 nil : [Int])))
(applyEachToEachN fs list)))))))
|