Last active
August 29, 2015 13:56
-
-
Save jcromartie/9099929 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 compile-unrolled | |
[f inputs] | |
(let [clauses (mapcat #(list % (f %)) inputs)] | |
`(fn [x#] | |
(case x# | |
~@clauses | |
(~f x#))))) | |
(defn unrolled | |
"Return a function with precomputed lookup for the given input domain." | |
[f inputs] | |
(eval (compile-unrolled f inputs))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment