[Haskell-cafe] Optimization problem
Henning Thielemann
lemming at henning-thielemann.de
Thu Sep 14 09:38:57 EDT 2006
On Wed, 13 Sep 2006, Magnus Jonsson wrote:
> When programming the other day I ran into this problem. What I want to do is a
> function that would work like this:
>
> splitStreams::Ord a=>[(a,b)]->[(a,[b])]
>
> > splitStreams [(3,x),(1,y),(3,z),(2,w)]
> [(3,[x,z]),(1,[y]),(2,[w])]
Interestingly we use such a routine in Haskore for splitting a sequence of
notes into sequences of notes of equal instruments. It's implemented
rather the same way like your version.
It's 'slice' in
http://darcs.haskell.org/haskore/src/Haskore/Basic/TimeOrderedList.lhs
but it is a bit more complicated because it has to manage time
information.
More information about the Haskell-Cafe
mailing list