Skip to content

Commit

Permalink
add Base.extrema (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch authored and ararslan committed Mar 14, 2018
1 parent 56e1d8e commit d13b0fa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/IntervalSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module IntervalSets
# package code goes here

using Base: @pure
import Base: eltype, convert, show, in, length, isempty, isequal, issubset, ==, hash, union, intersect, minimum, maximum, range
import Base: eltype, convert, show, in, length, isempty, isequal, issubset, ==, hash, union, intersect, minimum, maximum, extrema, range
if isdefined(Main, :)
import Base:
end
Expand Down
2 changes: 1 addition & 1 deletion src/closed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ hash(I::ClosedInterval, h::UInt) = hash(I.left, hash(I.right, hash(_closed_inter

minimum(I::ClosedInterval) = I.left
maximum(I::ClosedInterval) = I.right
extrema(I::ClosedInterval) = (minimum(I), maximum(I))

function intersect(A::ClosedInterval, B::ClosedInterval)
left = max(A.left, B.left)
Expand Down Expand Up @@ -105,4 +106,3 @@ end
range{I<:Integer}(i::ClosedInterval{I}) = convert(UnitRange{I}, i)

Base.promote_rule{T1,T2}(::Type{ClosedInterval{T1}}, ::Type{ClosedInterval{T2}}) = ClosedInterval{promote_type(T1, T2)}

1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ using Base.Test

@test maximum(I) === 3
@test minimum(I) === 0
@test extrema(I) === (0, 3)

@test 2 in I
@test 1..2 in 0.5..2.5
Expand Down

0 comments on commit d13b0fa

Please sign in to comment.