[Haskell-cafe] laziness blowup exercise

Thomas Hartman tphyahoo at gmail.com
Fri Jul 17 12:06:18 EDT 2009


I don't have a good answer to that, and I unable to reliably solve
this type of problem, which is one reason I am posting around on
haskell cafe hoping to accumulate wisdom.

Here for instance I think I did

t = last . take (10^6) $  repeat $ S.empty

which doesn't blow up, and by process of elimination figured the
process must be in iterate.

I then looked at iterate by writing myiterate (could have also copied
from hackage prelude) and thought about it until the answer (well, an
answer, maybe not the best one) came

myiterate f x = x : myiterate f (f x)

In general, I feel like I don't do very well solving these types of problems.


Am 17. Juli 2009 08:47 schrieb Matthias Görgens
<matthias.goergens at googlemail.com>:
> Thomas, if you did no know, where to look for `lazy-memory-hole', say
> in your first example, how would you go about solving that puzzle
> systematically with a Profiler (or other tools)?
>


More information about the Haskell-Cafe mailing list