Skip to content

Instantly share code, notes, and snippets.

@rbxbx
Created July 2, 2010 14:54
Show Gist options
  • Save rbxbx/461454 to your computer and use it in GitHub Desktop.
Save rbxbx/461454 to your computer and use it in GitHub Desktop.
; Clojure port of the scheme example from http://matt.might.net/articles/implementing-a-programming-language/
; Doesn't quite work. *shrug*
(defn any-eql? [x coll]
(filter #(= % x) coll))
(defn perform [func x]
(evaluate (nnext (first func))
(cons (list (fnext (first func)) (rest func)))))
(defn evaluate [expr env]
(cond
(symbol? expr)
(fnext (find expr env))
(= (first expr) 'λ)
(rest expr env)
:default (perform (evaluate (first expr) env)
(evaluate (fnext expr) env))))
(println (evaluate (read-line) '()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment