[Haskell-cafe] Haskell and "memoization"
gcross at phys.washington.edu
Tue Dec 15 23:08:39 EST 2009
Haskell does not maintain a cache mapping function calls to their values, so if you have some function f and call it with, say, the argument 7 in two different places in your code, then it will re-evaluate the function at each point. The only time it will not do this is when it can see explicitly that the value will be shared, i.e. situations like "g (f 7) (f 7)" should only result in one evaluation of f 7 in simple cases, presuming the compiler is sufficiently smart.
On Dec 15, 2009, at 7:32 PM, michael rice wrote:
> I'm looking here at the Fibonacci stuff:
> Since (I've read) Haskell never computes the value
> of a function more than once, I don't understand the
> need for memoization.
> Enlighten me.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe