Lizp is my experimental dialect of Lisp language.
Lizp is also an interpreter for this language written in Scala.
(include "std/std.lz")
(defn 'fib ['n]
(defn 'iter ['i 'a 'b]
(if (< i n)
(iter (+ i 1) b (+ a b))
a))
(if (= n 1) 0 (iter 0 0 1)))
(fib 1)
(fib 2)
(fib 10)
(fib 100)
Outputs:
> Nil // function definition returns Nil type
> 0
> 1
> 55
> 354224848179261915075
Bracket pairs ()
, []
and {}
are interchangeable, but all expressions must keep bracket-balance.
(def 'hello "Hello")
(defn 'greeting ['name] (println hello name))
(greeting "John")
(if (> 1 0) (println true) (println false))
(defn 'foo ['f 'a 'b] (f a b))
(foo (fn ['x 'y] (+ x y)) 10 20)
(include "path/to/another/script.lz")
All standard definitions are located in std/std.lz
(including macros defn
, defm
, etc.), so you may want put (include "std/std.lz")
into almost any program.
- [] optimization for tail-recursive functions (for very simple ones, as, for example,
iter
from the example above)