JuliaCollections / IterTools.jl

Common functional iterator patterns
Other
154 stars 29 forks source link

subsets() not working on Set() objects #27

Closed roberthoenig closed 6 years ago

roberthoenig commented 6 years ago
julia> for s in subsets(Set([1,2,3]))
           println(s)
       end
ERROR: MethodError: no method matching getindex(::Set{Int64}, ::Array{Bool,1})
Stacktrace:
 [1] next(::IterTools.Subsets{Set{Int64}}, ::Array{Bool,1}) at /home/robert/.julia/v0.6/IterTools/src/IterTools.jl:640
 [2] anonymous at ./<missing>:?

The docs say that subsets should work on collections. For me, it works for vectors, but not for sets. Am I doing something wrong?

iamed2 commented 6 years ago

subsets currently requires collections be indexable; use subsets(collect(my_set)) instead.

roberthoenig commented 6 years ago

If you want I can make a PR for either

iamed2 commented 6 years ago

A PR for the former would be appreciated :) Could you also change the docstring in src/IterTools.jl?