[Haskell] How to make sure that a function is evaluated only once?

Samuel Bronson naesten at gmail.com
Thu Dec 21 12:22:30 EST 2006

On 12/21/06, Axel Jantsch <axel at kth.se> wrote:

> I have a function with type
> f :: Int -> Int -> Int -> Int -> Int -> NRup -> NRdown
> and I want to make sure it is evaluated only once for the same set of
> arguments but I observe that it is always evaluated several times.

Maybe you want to memoize it? Memoization is when you wrap a function
so that its results are stored in a data structure indexed by
argument. This can be done either purely or impurely. What kind of
argument ranges are we talking about?

More information about the Haskell mailing list