I have a large stream of data, and want to break it into parts where 
subsequent elements define whether they belong to the same part or not.

A simple example will be the stream of integers, and the new part "starts" 
when there is a "hole" so [1,2,3,5,6,7,9] is logically "grouped" as 
[1,2,3],[5,6,7],[9]. 
The "real life" example is only complicated by how the predicate "elem -> 
elem -> Bool" works, so the idea stays the same.

I tried to use "groupsBy :: a -> a -> Bool" from "pipes-groups" library, 
and I need exactly this behaviour in terms of in/out, but it seems that the 
first argument of a predicate is always the first element of the group, not 
the previous element of a sequence.

I then tried to find if there is a simple way to produce a sliding window 
of 2 elements so I could still use "groupsBy" in a way:

 [1,2,3,5,6,7,9] -> [(1,1),(1,2),(2,3),(3,5),(5,6),(6,7),(7,9)] -> [(True, 
1), (True, 2), (True, 3), (False, 5), (True, 6), (True, 7), (False, 9)] -> 
[1,2,3],[5,6,7],[9]

But I couldn't find any sliding window combinator or library in pipes.

How do I solve this problem with Pipes?

Cheers,
Alexey.

-- 
You received this message because you are subscribed to the Google Groups 
"Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.

Reply via email to