David Roundy wrote:
> > stats elems = foldl add_elem Map.empty elems
> > add_elem m x = Map.insertWith (+) x 1 m
> [...]
> I tried defining
> 
> add_elem m x = let m' = Map.insertWith (+) x 1 m
>                    Just num = Map.lookup x m'
>                in seq num m'
> to force the (+) to be evaluated strictly, but that didn't help.

No, it doesn't, unless you also use foldl'.  Not tested, but been
there, seen it, bought the t-shirt.


Udo.
-- 
The Force is what holds everything together.  It has its dark side, and
it has its light side.  It's sort of like cosmic duct tape.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to