Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
def: Add defn-memo
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
Chouser committed Jul 9, 2009
1 parent c493df4 commit 4df3fae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/clojure/contrib/def.clj
Expand Up @@ -136,3 +136,12 @@ making private definitions more succinct."}
[~@pos & options#]
(let [~de-map (apply hash-map options#)]
~@body))))

; defn-memo by Chouser:
(defmacro defn-memo
"Just like defn, but memoizes the function using clojure.core/memoize"
[fn-name & defn-stuff]
`(do
(defn ~fn-name ~@defn-stuff)
(alter-var-root (var ~fn-name) memoize)
(var ~fn-name)))

0 comments on commit 4df3fae

Please sign in to comment.