donnie at darthik.com
Thu Dec 11 14:50:17 EST 2008
I think you will find this thread from the haskell-cafe mailing list quite
Re: [Haskell-cafe] Memoization
Also, the Haskell wiki contains comments about techniques for memoization
along with references at the bottom.
Haskell wiki Memoization:
Hope that helps.
On Thu, Dec 11, 2008 at 10:18 AM, Mattias Bengtsson <
moonlite at dtek.chalmers.se> wrote:
> The program below computes (f 27) almost instantly but if i replace the
> definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it
> takes around 12s to terminate. I realize this is because the original
> version caches results and only has to calculate, for example, (f 25)
> once instead of (i guess) four times.
> There is probably a good reason why this isn't caught by the compiler.
> But I'm interested in why. Anyone care to explain?
> > main = print (f 27)
> > f 0 = 1
> > f n = let f' = f (n-1)
> > in f' * f'
> (compiled with ghc --make -O2)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe