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