]> Witch of Git - ivy/blob - ivy-examples/fibonacci.vy
[test] Add a filecheck program
[ivy] / ivy-examples / fibonacci.vy
1 ; nextln: 0
2 ; nextln: 1
3 ; nextln: 1
4 ; nextln: 2
5 ; nextln: 3
6 ; nextln: 5
7 ; nextln: 8
8 ; nextln: 13
9 ; nextln: 21
10 ; nextln: 34
11 ; nextln: 55
12 ; nextln: 89
13 ; nextln: 144
14 ; nextln: 233
15 ; nextln: 377
16 ; nextln: 610
17 ; nextln: 987
18 ; nextln: 1597
19 ; nextln: 2584
20 ; nextln: 4181
21 ; nextln: 6765
22 ; nextln: 10946
23 ; nextln: 17711
24 ; nextln: 28657
25 ; nextln: 46368
26 ; nextln: 75025
27 ; nextln: 121393
28 ; nextln: 196418
29 ; nextln: 317811
30 ; nextln: 514229
31 ; nextln: 0
32
33 (let ([nil (lam (c n) (n))]
34 [cons (lam (x y) (lam (c n) (c x y)))]
35 [head true]
36 [fix (lam (f)
37 (let ([t (lam (x) (f (lam (v) (x x v))))])
38 (t t)))]
39 [if (lam (c t f) ((c t f)))])
40 ([fix (lam (recur a b l n)
41 (if (<= n 0)
42 [lam () (let [(_ (debug 0))] l)]
43 [lam () (recur b (+ (debug a) b) (cons a l) (- n 1))]))]
44 0 1 nil 30))