Merge pull request #210 from dubek/test-slurp-newline
[jackhill/mal.git] / tests / step5_tco.mal
CommitLineData
4e7296f9
JM
1;; Testing recursive tail-call function
2
3(def! sum2 (fn* (n acc) (if (= n 0) acc (sum2 (- n 1) (+ n acc)))))
4
5(sum2 10 0)
6;=>55
7
8(def! res2 nil)
9;=>nil
10(def! res2 (sum2 10000 0))
11res2
12;=>50005000
13
14
b25e3d29
JFI
15;; Test mutually recursive tail-call functions
16
17(def! foo (fn* (n) (if (= n 0) 0 (bar (- n 1)))))
18(def! bar (fn* (n) (if (= n 0) 0 (foo (- n 1)))))
19
20(foo 10000)
21;=>0