(def fib (memoize (lambda ...))) On Jul 22, 1:25 pm, Laurent PETIT <[email protected]> wrote: > 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 <[email protected]> > > > > > On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) > > logan <[email protected]> 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 <[email protected]> > >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 [email protected] > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > [email protected]<clojure%[email protected] > > > > > 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 [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
