Lisp interpreter. Ever since I got into Lisp and more specifically Clojure I've been fascinated by the Lisp eval/apply functions. How can something so small be so powerful? Naturally I had to implement a Lisp interpreter myself. This way I'll hopefully understand why it's so powerful.
I especially like the macro part. It's just an extra condition of apply. By adding this condition you get a macro system!!
The first 130 lines contains the interpreter. The following lines uses the interpreter to build an environment for the interpreter. Adding standard functions and macros such as reduce etc.
The code of the interpreter here [https://github.com/eliassona/mylisp/blob/master/src/mylisp/eval.clj]
I implemented this interpreter only because I wanted to understand the eval/apply of Lisp not because it is useable in any way (it is not).
Below are some examples.
The main function of the interpreter is called evl
(use 'mylisp.eval)
(evl (+ 1 1))
2Define a value
(evl (def a 1))
nil(evl a)
1Define a function
(evl (def a-fn (fn [x] (+ x 1))))
nilCall the function
(evl (a-fn 1))
2let is implemented as a macro using lambda
(evl
(let [a 1
b 2]
(+ a b)))
3