Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: combinations does not work for Sets #119

Open
schlichtanders opened this issue Feb 18, 2022 · 1 comment
Open

Bug report: combinations does not work for Sets #119

schlichtanders opened this issue Feb 18, 2022 · 1 comment

Comments

@schlichtanders
Copy link

to my full surprise the combinations function cannot deal with Sets directly.

As Sets support iterate and length, I think this is a bug

julia> collect(combinations(Set([1,2,3,4]), 2))
ERROR: MethodError: no method matching getindex(::Set{Int64}, ::Int64)
Stacktrace:
 [1] (::Combinatorics.var"#9#12"{Set{Int64}})(ci::Int64)
   @ Combinatorics ./none:0
 [2] iterate
   @ ./generator.jl:47 [inlined]
 [3] collect
   @ ./array.jl:724 [inlined]
 [4] reorder
   @ ~/.julia/packages/Combinatorics/Udg6X/src/combinations.jl:48 [inlined]
 [5] #10
   @ ./none:0 [inlined]
 [6] iterate
   @ ./generator.jl:47 [inlined]
 [7] collect(itr::Base.Generator{Combinatorics.Combinations, Combinatorics.var"#10#13"{Combinatorics.var"#reorder#11"{Set{Int64}}}})
   @ Base ./array.jl:724
 [8] top-level scope
   @ REPL[16]:1

Using Combinatorics v1.0.2 on Linux Julia 1.7.1

@Stivanification
Copy link

I don't think we should call this a bug, since the documentation for combinations says that it "generates all combinations of n elements from an indexable object". Since sets are not indexable, this behaviour is to be expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants