[Haskell-cafe] function result caching

Ketil Malde ketil+haskell at ii.uib.no
Fri Oct 13 16:15:03 EDT 2006

"Silviu Gheorghe" <ghesil.lists at gmail.com> writes:

> slowFunctionCacheList= [slowFunction (i) | i <-[0..5000000]]
> and use "slowFunctionCacheList !! i" instead of "slowFunction (i)"

> i am still curious about a better method (and a general one)

Not much different in principle, but better in practice - you could
use an array rather than a list.  O(1) lookups should make things (a
lot) faster.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list