Skip to content

Instantly share code, notes, and snippets.

@astrangeguy
Created February 26, 2010 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrangeguy/315254 to your computer and use it in GitHub Desktop.
Save astrangeguy/315254 to your computer and use it in GitHub Desktop.
(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