Skip to content

@bmabey /memoize_fn.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
memoized anonymous functions in clojure
; inspired from http://stackoverflow.com/questions/3906831/how-do-i-generate-memoized-recursive-functions-in-clojure
(defmacro memoize-fn
"Produces a memoized anonymous function that can recursively call itself."
[fn-name & fn-args]
`(with-local-vars
[~fn-name (memoize
(fn ~@fn-args))]
(.bindRoot ~fn-name @~fn-name)
@~fn-name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.