A LISP built in Rust. I followed Stepan Parunashvili's RISP tutorial, but borrowed a few concepts from Clojure.
Lana's REPL is a bit more powerful than RISP's. It has:
You can edit, undo, delete, search, etc. It has a colored output, and the last evaluated expression is
available in the alias _
:
Lana has a null value called nil
.
(nil? nil)
;; => true
(some? nil)
;; => false
Macro for evaluating a conditional. All values are accepted as a condition, false
and nil
are
the only falsey values.
(if true true false)
;; => true
(if 0 true false)
;; => true
(if false true false)
;; => false
(if nil true false)
;; => false
Macro for evaluating expressions in order and returns the value of the last one.
(do
(def x 40)
(def y 2)
(+ x y))
;; => 42
Syntax sugar for def
+ fn
.
(defn greet (who) (print "Hello, " who "!\n"))
(greet "Richy")
;; Hello, Richy!
(defn fib (n)
(if (<= n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
(fib 10)
;; => 89
You can see more examples under the examples directory.