Another solution, use the var, and then use memoize on your function as usual:
(defn fib[n] (if (> n 2) (+ (#'fib (- n 2)) (#'fib (- n 1)))) (of course this was to answer closely to the question. Nobody would write fib like that in practice : good general question, bad example) HTH, -- Laurent 2010/7/22 Mike Meyer <mwm-keyword-googlegroups.620...@mired.org> > On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) > logan <duskli...@gmail.com> wrote: > > > Lets say I have the following function > > > > (defn fib[n] > > (if (> n 2) > > (+ (fib (- n 2)) (fib (- n 1))) > > 1)) > > > > and I want to memoize it, what is the right way to do it? > > Use defn-memo from clojure.contrib.def. > > <mike > -- > Mike Meyer <m...@mired.org> > http://www.mired.org/consulting.html > Independent Network/Unix/Perforce consultant, email for more information. > > O< ascii ribbon campaign - stop html mail - www.asciiribbon.org > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en