IntervalSets.jl icon indicating copy to clipboard operation
IntervalSets.jl copied to clipboard

Multiple `union` operation is not supported

Open hyrodium opened this issue 3 years ago • 0 comments

Just like union([1,2], [2,3], [3,5]), the following operation should be supported.

julia> using IntervalSets

julia> union(1..2, 2..3)
1..3

julia> union(1..2, 2..3, 3..5)
ERROR: MethodError: no method matching iterate(::ClosedInterval{Int64})
Closest candidates are:
  iterate(::Union{LinRange, StepRangeLen}) at ~/julia/julia-1.7.1/share/julia/base/range.jl:826
  iterate(::Union{LinRange, StepRangeLen}, ::Integer) at ~/julia/julia-1.7.1/share/julia/base/range.jl:826
  iterate(::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} at ~/julia/julia-1.7.1/share/julia/base/dict.jl:695
  ...
Stacktrace:
 [1] mapfilter(pred::Base.var"#115#116"{typeof(∉), typeof(push!), Set{Int64}}, f::typeof(push!), itr::ClosedInterval{Int64}, res::Vector{Int64})
   @ Base ./abstractset.jl:443
 [2] _grow!
   @ ./array.jl:2607 [inlined]
 [3] union!(::Vector{Int64}, ::ClosedInterval{Int64}, ::ClosedInterval{Int64}, ::Vararg{ClosedInterval{Int64}})
   @ Base ./array.jl:2612
 [4] union(::ClosedInterval{Int64}, ::ClosedInterval{Int64}, ::ClosedInterval{Int64})
   @ Base ./abstractset.jl:50
 [5] top-level scope
   @ REPL[3]:1

hyrodium avatar Apr 09 '22 10:04 hyrodium