Created
July 22, 2014 20:38
-
-
Save msszczep/12168573f29159e86dfc to your computer and use it in GitHub Desktop.
Build an evaluator in Clojure (Lambda Jam 2014)
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
; variable evaluation: find and substitute | |
; look for Var X in B and substitute a | |
; environment, symbol | |
(def MyEnv {"One" 1 | |
"Two" 2 | |
"Three" 3 | |
"MyAdd" +}) | |
(defn MyEval [[term f & args]] | |
(cond | |
(= term "MyApply") (apply (MyEnv f) (map MyEnv args)) | |
:else "You Failed")) | |
(MyEval ["MyApply" "MyAdd" "One" "Two" "TwoA"]) | |
(MyEval ["cheese" "MyAdd" "One" "Two" "Three"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment