Re: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Laurent PETIT
2011/4/1 Ken Wesson kwess...@gmail.com On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/3/31 Ken Wesson kwess...@gmail.com On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Except in 1.3 it will be a little bit harder

Re: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Ken Wesson
On Fri, Apr 1, 2011 at 1:59 AM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/4/1 Ken Wesson kwess...@gmail.com On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/3/31 Ken Wesson kwess...@gmail.com On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT

Re: (memoize) and recursive functions (Clojure 1.2)

2011-04-01 Thread Laurent PETIT
2011/4/1 Ken Wesson kwess...@gmail.com On Fri, Apr 1, 2011 at 1:59 AM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/4/1 Ken Wesson kwess...@gmail.com On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/3/31 Ken Wesson kwess...@gmail.com On

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-31 Thread Laurent PETIT
2011/3/31 Ken Wesson kwess...@gmail.com On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Except in 1.3 it will be a little bit harder to do throw-away per-thread memoizes for vars you do no own if their author didn't make their holding var :dynamic ('cause

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-31 Thread Ken Wesson
On Thu, Mar 31, 2011 at 3:24 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/3/31 Ken Wesson kwess...@gmail.com On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Except in 1.3 it will be a little bit harder to do throw-away per-thread memoizes for vars

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-30 Thread Ken Wesson
On Wed, Mar 30, 2011 at 12:02 PM, Laurent PETIT laurent.pe...@gmail.com wrote: Except in 1.3 it will be a little bit harder to do throw-away per-thread memoizes for vars you do no own if their author didn't make their holding var :dynamic ('cause then you will not be able to rebind them).

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-29 Thread Mark Nutter
I just saw this in another thread. Try this version instead: (defn f [n] (println f called with n) (if (zero? n) 0 (min (#'f (dec n)) (#'f (dec n) What's happening is that inside the body of f, the f is a symbol whose contents point to the anonymous function being

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-29 Thread Benny Tsai
Andreas, Mark, thank you for your suggestions. Both worked splendidly. Just out of curiosity, does memoize in 1.3 behave like the current 1.2 version or the 1.1 version? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-29 Thread Sean Corfield
On Tue, Mar 29, 2011 at 8:31 AM, Benny Tsai benny.t...@gmail.com wrote: Just out of curiosity, does memoize in 1.3 behave like the current 1.2 version or the 1.1 version? user= (clojure-version) 1.3.0-alpha4 user= (defn f [n] (println f called with n) (if (zero? n) 0 (min (f (dec

Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-29 Thread Benny Tsai
Fantastic! Thank you Sean. On Tuesday, March 29, 2011 11:37:06 AM UTC-6, Sean Corfield wrote: On Tue, Mar 29, 2011 at 8:31 AM, Benny Tsai benny...@gmail.com wrote: Just out of curiosity, does memoize in 1.3 behave like the current 1.2 version or the 1.1 version? user= (clojure-version)

(memoize) and recursive functions (Clojure 1.2)

2011-03-28 Thread Benny Tsai
I was playing with memoize when I ran into some puzzling behavior. A test case: (defn f [n] (println f called with n) (if (zero? n) 0 (min (f (dec n)) (f (dec n) (def f (memoize f)) *The usage of def to rebind a function to its memoized version is taken from