yorick: Fix evaluation of empty vectors in steps 2 and 3
[jackhill/mal.git] / impls / tests / computations.mal
CommitLineData
3e9b89d4
NB
1;; Some inefficient arithmetic computations for benchmarking.
2
3;; Unfortunately not yet available in tests of steps 4 and 5.
4
5;; Compute n(n+1)/2 with a non tail-recursive call.
6(def! sumdown
7 (fn* [n] ; non-negative number
8 (if (= n 0)
9 0
10 (+ n (sumdown (- n 1))))))
11
12;; Compute a Fibonacci number with two recursions.
13(def! fib
14 (fn* [n] ; non-negative number
15 (if (<= n 1)
16 n
17 (+ (fib (- n 1)) (fib (- n 2))))))