On Tue, 20 Jul 2010 13:11:12 -0700 (PDT)
Aravindh Johendran wrote:
> If we have tree recursive procedure such as the follows, how can we
> use memoize it so that it automatically caches the values it has
> already computed .
[example elided]
> Maybe memoize should go the same way as the co
On 20 July 2010 23:41, Moritz Ulrich wrote:
> I think the tour problem is the (def m-fib (memoize fib)). You create
> a new memoized function m-fib, while fib will internally call the
> non-memoized fib. You have to do something like: (binding [fib
> (memoize fib)] (fib 42)).
> However, this will
Offtopic: Java doesn't support tail-recursive calls, so your fib will
blow up the stack for larger ns. Use recur for recursion.
I think the tour problem is the (def m-fib (memoize fib)). You create
a new memoized function m-fib, while fib will internally call the
non-memoized fib. You have to do s
If we have tree recursive procedure such as the follows, how can we
use memoize it so that it automatically caches the values it has
already computed .
(defn fib [n]
(println "Calling fib with arg --> " n)
(cond
(= n 0) 0
(= n 1) 1
:else (+ (fib (- n 1))
(fib (- n 2)))