Skip to content

union, unionBy are not symmetrical in their arguments #56

@sharkdp

Description

@sharkdp

This seems weird:

union [0, 0] [1, 1] == [0, 0, 1]

I would have expected the result to be [0, 1], but at least it should be symmetrical in both arguments. I would consider several possible fixes:

  1. Remove all duplicates (i.e. union a b == nub (a <> b))
  2. Keep the duplicates within both of the arguments (i.e. union [0, 0] [1, 1] == [0, 0, 1, 1]).
  3. Remove union and unionBy from Data.Array (given that Set is the better data structure for something like this)
  4. Document the behavior if it is intended

I would vote for 1 or 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions