A little magical language 🧙♂️
Arcanya is a interpreted LISP like language built in Rust.
It is a hobby project of mine that I created to learn more about the LISP family. I was frustrated with the syntax, so I created my own.
It supports:
- Integers
- Floats
- Strings
- Symbols
- Functions
- Builtins
- Mapping
- Folding (or reducing)
- Filtering
- Partial function application 😍
- and more..
To try it out, just run
cargo run
Which starts a interactive Arcanya session.
The only way for now to install is to:
git clone https://github.com/jameender/arcanya
cd arcanya
cargo run
You can print any variable using print
(print "hello world")
Defining global variables can be done with define
(define 'x 5)
(define 'y 7)
(+ x y)
; 12
Defining local variables can be done with let
(let 'x 5
(let 'y 7
(+ x y)
)
)
; 12
Or by using let multiple with let*
(let* '(
(x 5)
(y 7)
) (+ x y))
; 12
You can map over lists with map
(map
(function '(x) '(* x 2))
'(1 2 3)
)
; (2 4 6)
And fold over lists with fold
(fold '+ 0 '(1 2 3))
; 6
Concat strings with concat
(concat
"Arcanya "
"is "
"gorgeous" "!"
)
; you can figure that out ;)
Example program for generating Fibonacci numbers
(define 'fibonacci (function '(x) '(and-then
(define 'nums '(0 1))
(for 'i (range 0 (- x 2))
'(define 'nums
(list
(nth 1 nums)
(+ (nth 0 nums) (nth 1 nums)))))
(nth 1 nums)
)))
(fibonacci 10)