H
mm..
The totals in "sum" and "count" are not computed until printed. This is too
lazy. You start with '0' and (+) things to it, but never examine or force the
value, so man many (+) thunks are built up in memory.
If you use bang patterns then the change can be made here, to !sum !count:
check_line line !sum !count =
let match = matchRegex regexp line
in case match of
Just strs -> (sum + read (head strs) :: Integer, count + 1)
Nothing -> (sum, count)
This will force evaluation before every check_line call.
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell