Rust implementation of iamlisp with iterative evaluation of program.
- Scalar literals:
-
Int64
-
Float64
-
Boolean
-
String
-
Nil
-
-
Set
-
Map
-
Vector
- Math operations:
-, +, *, /, //, %, pow, sqrt, max, min
- Logic operations:
>, <, >=, <=, =, !=, !, !!
- Keyword
def
- Keyword
quote
- Keyword
lambda
- Keyword
macro
- Keyword
cond
- Keyword
loop
- Keyword
defun
- Keyword
defmacro
- Keyword
macroexpand
- Methods for
List
,Vector
manipulation:map, filter, reduce, find, includes?, some, any
- Methods for
Set
,Map
manipulation:add, has, delete
- Lambda arguments destructuring
- Tail call optimization
(def a 10 b 20)
(def foo "Hello World")
(def bar true)
(defun sum (a b) (+ a b))
(defmacro backwards (. body) (eval (cons 'begin (.reverse 'body))))
(def my-lambda (lambda (a b) (+ a b)))
; Print numbers from 100 to 0
(loop (x 100)
(print x)
(cond ((> x 0) (recur (dec x)))))
; Fibonacci using iterative loop
(defun fib (n)
(loop (x 0 y 1 i n)
(cond ((<= i 0) x) ((recur y (+ x y) (dec i))))))
; Nested destructuring
(def (a (b c)) '(2 '(4 6)))
; Destructuring with rest
(def (first . rest) '(1 2 3 4 5))