[Haskell-cafe] Haskell and "memoization"

Gregory Crosswhite 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:
> http://www.haskell.org/haskellwiki/Memoization
> 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.
> Michael
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091215/b2125b01/attachment.html

More information about the Haskell-Cafe mailing list