Created
September 10, 2016 12:22
-
-
Save missingfaktor/c1341c4e2c423c9e3d4a2656c0f83f9e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (defn evaluate [exp] | |
| (match exp | |
| (:variant :val [x]) x | |
| (:variant :add [x y]) (+ (evaluate x) (evaluate y)) | |
| (:variant :multiply [x y]) (* (evaluate x) (evaluate y)))) | |
| (def numeric-expression | |
| [:add [:val 2] | |
| [:multiply [:val 4] | |
| [:val 5]]]) | |
| (evaluate numeric-expression) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment