Skip to content

group and groupBy #192

Description

@andrewthad

In Data.List, we have:

group :: Eq a => [a] -> [[a]]
groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

I would like to introduce analogous version into vector:

group :: Eq a => Vector -> [Vector a]
groupBy :: (a -> a -> Bool) -> Vector a -> [Vector a]

These have the potential to be much more space efficient than the list equivalents since they share the underlying array with the original vector. Would this be accepted if I added it?

Activity

  1. radrow commented on Mar 28, 2018

    @radrow

    I actually need this feature, it would be really cool if this could be added

  2. andrewthad commented on Mar 28, 2018

    @andrewthad
    ContributorAuthor

    Do any of the maintainers have any thoughts on this?

  3. cartazio commented on Mar 28, 2018

    @cartazio
    Contributor
  4. radrow commented on Mar 29, 2018

    @radrow

    That's a good question - if somebody wants to play with vectors he won't probably want to use lists suddenly at same place. From the other hand he will not need random access at the start, because placement and number of groups is quite unpredictable.

  5. andrewthad commented on Mar 29, 2018

    @andrewthad
    ContributorAuthor

    There is a little bit of precedent for using list instead of vector. Consider the signature for Data.Vector.concat, which takes a list and not a vector. I think list is probably a better choic here because it means that the the type signature for the Unboxed vector variant will be consistent.

  6. BebeSparkelSparkel commented on Jan 15, 2020

    @BebeSparkelSparkel
  7. tchoutri commented on Dec 6, 2021

    @tchoutri

    Would love to see this happen as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions