On Sep 14, 2006, at 03:05 , Rohan Drape wrote:
splitStreams [(3,x),(1,y),(3,z),(2,w)]
[(3,[x,z]),(1,[y]),(2,[w])]
[snip]
Furthermore it should work on infinite lists. It can't eat the whole
list before producing any output.
This doesn't seem to make sense? Only at the end of the list can you
know that you've collected all the events for each channel. If you
output anything before scanning to the end, you'd not know if there
were perhaps more events on that channel?
It makes good sense. Each list will of events will be evaluated
lazily, so thing will appear there as they appear in the input.
I don't think you can do it in Haskell without some magic in the IO/
ST monad.
In LML we had an array construction function that did almost exactly
what the O.P. asked for.
-- Lennart
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe