[Haskell-cafe] multiple computations, same input

Greg Fitzgerald garious at gmail.com
Mon Mar 27 17:22:13 EST 2006

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

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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20060327/985bdf78/attachment-0001.htm

More information about the Haskell-Cafe mailing list