[Haskell-cafe] function result caching

Silviu Gheorghe ghesil.lists at gmail.com
Thu Oct 12 18:27:38 EDT 2006

it does, thank you very much for the quick answer, unfortunately as I
understand it, it doesn't work well on ints :(

for just now i created a list

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

it helped alot (i mean i stoped the program after "3 hours still working"
and got the result in 2 minutes :))

i am still curious about a better method (and a general one), because this
is ugly, and it only works on ints as i see it.

but then again thank you for telling me it doesn't do it, because i had the
false impresion it does and i wouldn't stop it otherwise

On 10/13/06, Tom Phoenix <rootbeer at redcat.com> wrote:
> On 10/12/06, Silviu Gheorghe <ghesil.lists at gmail.com> wrote:
> > I'd like to know if the results are "cached"  by the compiler
> Hardly ever, as I understand things.
> > if they are not I'd like to know what is the best way to cache them
> > manually, and where can I read more about this, and the optimizations
> the
> > compiler does, because I've searched the web before and i found very
> little
> > on this topic.
> You need to search for the word "memoize" (or "memoise"). Here's a
> page about a memo function for GHC.
>     http://www.haskell.org/ghc/docs/6.4.2/html/hslibs/memo-library.html
> Hope this helps!
> --Tom Phoenix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20061013/95abafa1/attachment.htm

More information about the Haskell-Cafe mailing list