[Haskell-cafe] Re: k-minima in Haskell

Mark T.B. Carroll mark at ixod.org
Thu Apr 12 22:51:34 EDT 2007

Dan Weston <westondan at imageworks.com> writes:

> 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

More information about the Haskell-Cafe mailing list