Minimalistic LISP dialect implemented in Scala.
- strings
(def str "wololo")
- numeric
(def num1 123)
(def num2 12.32)
- collections
- maps
{k1 v1 k2 v2}
- sequences
- lists
`(a b c)
- vectors
[a b c]
- lists
- maps
- nil
nil
- prefix-operators
- backtick
`
- prevents evaluation - ampersand
&
- for passing varargs - tilda
~
- unimplemented - dot
.
- unimplemented
- backtick
-
+, -, *, div, mod
-
eq, lt, lte, gt, gte
-
and, or, not
-
nothing?, str?, coll?, seq?, map?, vector?, list?, num?, func?, bool?, identifier?
-
-
head seq, tail seq, init seq
-
take n seq, drop n seq
-
conj seq x, cons x seq
-
-
(if (eq 2 1) then "2 equals 1" else "1 equals 1") ==> "1 equals 1"
-
-
(map f coll)
-
(filter f coll)
-
(reduce f start coll)
-
-
-
(fn [x y] (+ x y))
-
-
-
(def x 3)
-
(def x "wololo")
-
or shorter:
(def func (fn [x y] (+ x y)))
(defn func [x y] (+ x y))
-
-
-
(let {foo 21 bar 37} (+ foo bar)) ==> 58
-
(defn fact [x] (let {f (fn [acc x] (if (eq x 1) then acc else (f (* acc x) (- x 1))))} (f 1 x))) (fact 5) ==> 120
-
-
(defn sum [&nums] (reduce + 0 nums)) (sum 1 2 3) ==> 6
-
-
(defn fib [] (let {f (fn [a b] (lazy-seq (cons b (f b (+ a b)))))} (f 0 1) )) (take 3 (drop 2 (fib))) ==> [2, 3 ,5]
-
(defn mults [num] (let {f (fn [i] (* i num)) g (fn [i] (lazy-seq (cons (f i) (g (+ i 1)))))} (g 1))) (take 5 (mults 5)) ==> [5, 10, 15, 20, 25]
-
- negative numbers parsing, to make one:
(- 0 num)
- maps manipulation functions
- IO
- some kind of better conditions handling, like
cond
from Clojure - macros definitions
- and lots of other stuff, too
Check here