MWE:
julia> s = Set([1, 4, 5]);
julia> findall(x -> x > 3, s)
ERROR: MethodError: no method matching keys(::Set{Int64})
Closest candidates are:
keys(::Cmd) at process.jl:639
keys(::Core.SimpleVector) at essentials.jl:603
keys(::Tuple) at tuple.jl:64
...
Stacktrace:
[1] pairs(::Set{Int64}) at ./abstractdict.jl:134
[2] findall(::var"#29#30", ::Set{Int64}) at ./array.jl:2108
[3] top-level scope at REPL[29]:1
Defining
Base.keys(s::Set) = Base.keys(s.dict)
solves this.
Why should findall work on Sets? findall returns the indices of the elements for which the predicate returns true, but a Set does not have indices.
You're correct. I was looking for the function that returned the elements satisfying the predicate. Sorry for the noise.
EDIT: That function is filter.
Most helpful comment
Why should
findallwork onSets?findallreturns the indices of the elements for which the predicate returnstrue, but aSetdoes not have indices.