summaryrefslogtreecommitdiff
blob: 526cbe4f49e1825509d34b7290bac6942eaaaaa6 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(fate_version 1)

(global string test_name)

(set test_name ( FILTER ))

(global (list int) 0to10)

(set 0to10 (range 0 10 1))

(assert
   (= 55
      (foldl
         (lambda ((int res) (int e)) (+ res e))
         0
         0to10
      )
      (foldr
         (lambda ((int res) (int e)) (+ res e))
         0
         0to10
      )
   )
   [FAILED] (var test_name) Failed sum.
   (newline)
   foldl yielded:
   (foldl
      (lambda ((int res) (int e)) (+ res e))
      0
      0to10
   )
   (newline)
   foldr yielded:
   (foldr
      (lambda ((int res) (int e)) (+ res e))
      0
      0to10
   )
)

(global (list string) ls)

(local int i)
(for (set i 0) (=< i 10) (set i (+ i 1))
   (add! (cast string (var i)) ls)
)

foldl:
(foldl
   (lambda ((text res) (string e)) (text (var res) (var e)))
   (default text)
   ls
)
(newline)
foldr:
(foldr
   (lambda ((text res) (string e)) (text (var res) (var e)))
   (default text)
   ls
)

[COMPLETED] (var test_name)

(end)