[Haskell-cafe] Memoization local to a function

Henning Thielemann lemming at henning-thielemann.de
Wed Feb 25 16:44:51 EST 2009


On Wed, 25 Feb 2009, Luke Palmer wrote:

> On Wed, Feb 25, 2009 at 10:38 AM, Dusan Kolar <kolar at fit.vutbr.cz> wrote:
>        I have a function a computation of which is quite expensive, it is recursively
>       dependent on itself with respect to some other function values - we can roughly
>       model its behaviour with fib function (returns n-th number of Fibonacci's
>       sequence). Unfortunately, it is not fib, it is far more complicated.
>       Nevertheless, for demonstration of my question/problem I will use fib, it's quite
>       good.
> 
> 
> I suggest using data-memocombinators for this rather than rolling your own.  It accomplishes
> the same thing, but makes the choice of memo structure independent of the code that uses it
> (and Memo.integral has asymptotically better performance than a list).

Nice to know that there is a package for this purpose. See also
   http://haskell.org/haskellwiki/Memoization


More information about the Haskell-Cafe mailing list