implement bytecode interpreter and compiler
This commit is contained in:
parent
d23a9a4827
commit
c63c1eaf6e
19 changed files with 1055 additions and 547 deletions
17
test.lisp
Normal file
17
test.lisp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(def fib-iter (fn (n a b)
|
||||
(if (= n 0)
|
||||
a
|
||||
(fib-iter (- n 1) b (+ a b)))))
|
||||
(def fib (fn (n) (fib-iter n 0 1)))
|
||||
|
||||
(write "(fib 50) = ")
|
||||
(println (fib 50))
|
||||
|
||||
(def sum
|
||||
(fn (n acc)
|
||||
(if (= n 0)
|
||||
acc
|
||||
(sum (- n 1) (+ n acc)))))
|
||||
|
||||
(write "(sum 1000000) = ")
|
||||
(println (sum 1000000 0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue