How do I perform multiple computations on a long lazy list without introducing a space leak?<br><br>Doing a single computation like this works great:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f = show . filter (&gt; 1)<br><br>But if I do something like this:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f lst = show (filter (&gt; 1) lst, filter (&gt; 2) lst)<br>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.
<br><br>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?<br><br>Thanks,<br>Greg<br><br><br><br>