Skip to content

Commit 8d987e3

Browse files
omusspurll
authored andcommitted
Reduce Interval methods for arithmetic
1 parent 96a6d15 commit 8d987e3

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

src/interval.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,10 @@ end
136136

137137
##### ARITHMETIC #####
138138

139-
function Base.:+(a::Interval{T}, b::T) where T
140-
return Interval{T}(first(a) + b, last(a) + b, inclusivity(a))
141-
end
142-
143-
function Base.:+(a::Interval{Char}, b::Integer)
144-
return Interval{Char}(first(a) + b, last(a) + b, inclusivity(a))
145-
end
146-
147-
function Base.:+(a::Interval{T}, b::Period) where T <: TimeType
148-
return Interval{T}(first(a) + b, last(a) + b, inclusivity(a))
149-
end
150-
151-
Base.:+(a::T, b::Interval{T}) where T = b + a
152-
Base.:+(a::Integer, b::Interval{Char}) = b + a
153-
Base.:+(a::Period, b::Interval{T}) where T <: TimeType = b + a
139+
Base.:+(a::T, b) where {T <: Interval} = T(first(a) + b, last(a) + b, inclusivity(a))
154140

155-
Base.:-(a::Interval{T}, b::T) where T = a + -b
156-
Base.:-(a::Interval{Char}, b::Integer) = a + -b
157-
Base.:-(a::Interval{T}, b::Period) where T <: TimeType = a + -b
141+
Base.:+(a, b::Interval) = b + a
142+
Base.:-(a::Interval, b) = a + -b
158143

159144
Base.:-(a::T, b::Interval{T}) where T = a + -b
160145

0 commit comments

Comments
 (0)