[Haskell-cafe] Optimization problem
brian at ithil.org
Fri Sep 15 05:28:35 EDT 2006
On 15/09/06, Lennart Augustsson <lennart at augustsson.net> wrote:
> 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.
But even if you could do it, its very hard to safely /use/ the result.
Looking for the next event on any channel runs the risk that actually there
are no more events ever on that channel, and a resultant scan to the end of
the infinite list!
Brian_Brunswick____brian at ithil.org____Wit____Disclaimer____!Shortsig_rules!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe