You can find the source code here
Architecture
- Tokenizer
- Text Parser
- BuiltIn
- Environment
- AST
- Macro Compiler
- Evaluator
Features
true | * | == | > | or | list | rm_head | cons | foldl |
---|---|---|---|---|---|---|---|---|
false | / | <= | def | if | push_back | rm_tail | max | map |
+ | % | >= | set | while | head | nth_element | min | |
- | ! | < | and | func | tail | size | filter |
Sample of Abstract Syntax Tree
Fibonacci sequence recuesive version
(function fib (n)
(if
(< n 2)
n
(+
(fib (- n 1))
(fib (- n 2))
)
)
)
Sample Results
Fibonacci sequence iterative version
(def a (list 0 1 1))
(function fib(n)
(while
(< (size a) n)
(push_back a
(+
(nth_element(- (size a) 1) a)
(nth_element(- (size a) 2) a)
)
)
)
)
Function and Higher Order Function
Example of the filter function.
(def a (list 1 2 3 4))
(function even (x)
(if
(== (% x 2) 0)
true
false
)
)
(filter even a)
Example of foldl function.
(def a (list 1 2 3 4))
(function sum(x y) (+ x y))
(foldl sum 10 a)
You can also implement your own logic for map, foldl and filter function.
Function Overloading
Example of sum function overloading.
(function add (a b) (+ a b))
(function add (a b c) (+ a b c))