Created
February 26, 2010 00:45
-
-
Save astrangeguy/315254 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
(defn memoize-visble-atom [f] | |
(let [mem (atom {})] | |
(with-meta | |
(fn [& args] | |
(if-let [e (find @mem args)] | |
(val e) | |
(let [ret (apply f args)] | |
(swap! mem assoc args ret)))) | |
{:memoize-atom mem}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment