[Haskell-cafe] eager/strict eval katas

Thomas Hartman thomas.hartman at db.com
Wed Dec 12 11:31:33 EST 2007


I'm trying to get a better handle on eager/strict eval in haskell, and a 
great way to do this is by building up from simple exercises to harder 
exercises.

So far I have

exercise 1) add the integers [1..10^6] 
  (stack overflows if you do a naive fold, as described on wiki)

exercise 2) find the first integer such that average of [1..n] is > [10^6] 

  (solution involves building an accum list of (average,listLength) 
tuples. again you can't do a naive fold due to stack overflow, but in this 
case even strict foldl' from data.list isn't "strict enough", I had to 
define my own custom fold to be strict on the tuples.)

anybody got other suggestions, or links to places where eager eval is 
required to solve simply stated problems? or exercises that demystify 
doing eager IO/eager whatever monad,  where that is required?

Also am I correct that the terms eager and strict can be used more or less 
interchangeably in this problem space?

Tired of this folk wisdom that haskell is only for the elite because 
getting around stack overflow from lazy eval is impossible to teach to 
newbies.

t.

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071212/e679e704/attachment.htm


More information about the Haskell-Cafe mailing list