Created
July 2, 2010 14:54
-
-
Save rbxbx/461454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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