
12 Apr
2007
12 Apr
'07
10:51 p.m.
Dan Weston
Ah, but which k elements? You won't know until you've drained your entire stream!
True, but you still don't need to keep the whole stream in memory at once, just the k-least-so-far as you work your way through the stream - once you've read a part of the stream you can mostly forget it again. The question as I understood it was one of if even in Haskell there's a better way than sorting that means you need only have a fragment of the stream in memory at once. -- Mark