Skip to content

issetequal behavior with duplicate elements #32550

Closed
@pearlzli

Description

@pearlzli

As I mentioned on Discourse, the issetequal docstring says that issetequal(a, b) is equivalent to a ⊆ b && b ⊆ a, but this isn't the case when there are duplicate elements:

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)

julia> a = [1,2,3];

julia> b = [1,1,2,3];

julia> a ⊆ b && b ⊆ a
true

julia> issetequal(a, b)
false

This is because the implementation assumes no duplicate elements:

issetequal(l, r) = length(l) == length(r) && l ⊆ r

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcollectionsData structures holding multiple items, e.g. setsgood first issueIndicates a good issue for first-time contributors to Juliahelp wantedIndicates that a maintainer wants help on an issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions