How do I perform multiple computations on a long lazy list without introducing a space leak?

Doing a single computation like this works great:
      f = show . filter (> 1)

But if I do something like this:
      f lst = show (filter (> 1) lst, filter (> 2) lst)
then it looks like GHC won't garbage collect list elements until the first filter has completely finished, and the second filter has iterated over them.

Is there an easy way to feed each element into both functions, instead of feeding all elements to one function, and then all to the next?

Thanks,
Greg



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

Reply via email to