[Haskell-cafe] Memoization/call-by-need

Conal Elliott conal at conal.net
Wed Sep 15 22:39:35 EDT 2010

Hi Alex,

In Haskell, data structures cache, while functions do not.

"Memoization" is conversion of functions into data structures (and then
trivially re-wrapping as functions) so as to exploit the caching property of
data structures to get caching functions.

  - Conal

On Wed, Sep 15, 2010 at 11:03 AM, Alex Rozenshteyn <rpglover64 at gmail.com>wrote:

> I feel that there is something that I don't understand completely:  I have
> been told that Haskell does not memoize function call, e.g.
> > slowFib 50
> will run just as slowly each time it is called.  However, I have read that
> Haskell has call-by-need semantics, which were described as "lazy evaluation
> with memoization"
> I understand that
> > fib50 = slowFib 50
> will take a while to run the first time but be instant each subsequent
> call; does this count as memoization?
> (I'm trying to understand "Purely Functional Data Structures", hence this
> question)
> --
>           Alex R
> _______________________________________________
> 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/20100915/9490dec8/attachment.html

More information about the Haskell-Cafe mailing list