[Haskell-cafe] eager/strict eval katas
Don Stewart
dons at galois.com
Wed Dec 12 15:58:50 EST 2007
benja.fallenstein:
> Hi Thomas,
>
> On Dec 12, 2007 5:31 PM, Thomas Hartman <thomas.hartman at db.com> wrote:
> > (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.)
>
> Might it be worthwhile considering the use of a custom strict pair
> type instead of rewriting the strict fold functions? I.e., define
>
> data Pair a b = Pair !a !b
>
> and then use ordinary foldl' and foldr' on that.
And no need to even use custom ones, just use the library strict pairs,
http://hackage.haskell.org/packages/archive/strict/0.2/doc/html/Data-Strict-Tuple.html
Reuse! Reuse!
More information about the Haskell-Cafe
mailing list