-
Notifications
You must be signed in to change notification settings - Fork 27
Closed as not planned
Description
Would it be helpful to add a type holding a tuple of disjoint intervals. I personally need this for my application and coded it up just using Tuples
Base.:\(a::Interval, b::Interval) = filter(r->r.left≤r.right,mapreduce(bᶜ-> a ∩ bᶜ, TupleTools.vcat, -b))
Base.:-(a::Interval) = ((-Inf .. a.left),(a.right .. Inf))
Base.:\(A::Tuple,b::Interval) = mapreduce(a -> a\b, TupleTools.vcat, A)
Base.:∩(A::Tuple,B::Tuple) = filter(!isempty,Tuple(a ∩ b for a in A, b in B))
Base.:∪(A::Tuple, b::Interval) = foldl((a,b)->isempty(a ∩ b) ? (a, b) : (a ∪ b,), A; init=b)
Base.:\(A::Tuple,B::Tuple) = mapreduce(a -> foldl(\, B; init = a), TupleTools.vcat, A)We could define a DisjointIntervals type and make these operators a bit more robust. Any interest in that?
Metadata
Metadata
Assignees
Labels
No labels