Applied step 5 TCO

- Some tests disabled for incompatibility
- next step is to restore those tests, as well as a whole "eval" test
This commit is contained in:
teo3300
2023-12-21 19:25:24 +09:00
parent c6eeb225df
commit 0b47444836
6 changed files with 191 additions and 83 deletions

View File

@ -1,10 +1,9 @@
(def! n-fib (fn* (n)
(if (<= n 0) 0 ; 0 base case
(if (= n 1) 1 ; 1 base case
(+ (n-fib (- n 1)) (n-fib (- n 2))))))) ; recursive
(if (< n 2) n ; base
(+ (n-fib (- n 1)) (n-fib (- n 2)))))) ; recursive
(def! assert-fib (fn* (n expected) ; check fibonacci result
(if (= (n-fib n) expected) nil
(if (not (= (n-fib n) expected))
(do (prn (list
"Expected"
expected