On Dec 6, 2008, at 9:48 PM, Paul Mooser wrote:

I also saw your subsequent example which uses a different anonymous
function which does NOT blow up, and that's very interesting. I'm not
sure why this would be, but it seems that filter ends up holding on to
the collection its filtering internally from the point at which it
first matches - I think the second one doesn't blow up because it
doesn't happen until almost the end.

I agree with this as the reason why the second example worked.

When filter finds a match it tries to construct a lazy cons of the first of the match (which in this case is a one of the members of the sequence) and the rest which it then goes on to fully realize. The first is still hooked up to that rest and since it's being retained, the entire sequence stays in memory.

Somehow the "first" needs to shed its rest before we construct the new lazy_cons. I'm still thinking about the details of that.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to