Alright, I added `groupsBy'` with your desired behavior here (and some doctests to verify that it behaves the way you requested):

https://github.com/Gabriel439/Haskell-Pipes-Group-Library/commit/cbaf79d613e0b24fc0f89210b3d264000453c174

I will probably not add an equivalent `groups'` function for now, if that is alright with you.

Let me know if that is what you needed and if it is then I will upload this to Hackage.

On 8/9/2015 5:56 PM, ar...@arbor.net wrote:
That would be incredibly helpful, thank you very much! Can't wait to use it!

Cheers,
Alexey.

On Monday, August 10, 2015 at 10:32:07 AM UTC+10, Gabriel Gonzalez wrote:

    If you want, I could add a variation on `groupsBy` named
    `groupsBy'` that does the grouping using adjacent elements

    On 8/9/2015 5:21 PM, ar...@arbor.net <javascript:> wrote:
    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-pipe...@googlegroups.com <javascript:>.
    To post to this group, send email to haskel...@googlegroups.com
    <javascript:>.

--
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 <mailto:haskell-pipes+unsubscr...@googlegroups.com>. To post to this group, send email to haskell-pipes@googlegroups.com <mailto:haskell-pipes@googlegroups.com>.

--
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