From a599edc6284f77fc24e8eefc854b78042a154f61 Mon Sep 17 00:00:00 2001 From: prashantrahul141 Date: Wed, 12 Mar 2025 12:15:21 +0530 Subject: [PATCH 1/2] impl: 3 argument show method for UnitRange --- base/show.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/show.jl b/base/show.jl index d66651e086654..be049ae0003df 100644 --- a/base/show.jl +++ b/base/show.jl @@ -12,6 +12,13 @@ end show(io::IO, ::MIME"text/plain", r::AbstractRange) = show(io, r) # always use the compact form for printing ranges +function show(io::IO, ::MIME"text/plain", r::UnitRange) + print(io, repr(first(r)), ':', repr(last(r))) + if isempty(r) + print(io, " (empty range)") + end +end + function show(io::IO, ::MIME"text/plain", r::LinRange) isempty(r) && return show(io, r) # show for LinRange, e.g. From ba4887f2e411881e93b55826d6bb4cb6a7cbc883 Mon Sep 17 00:00:00 2001 From: prashantrahul141 Date: Wed, 12 Mar 2025 12:15:30 +0530 Subject: [PATCH 2/2] fix: doctest --- base/sort.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index 8254f56b3f952..0b712e6a9bc3e 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -336,13 +336,13 @@ julia> searchsorted([1, 2, 4, 5, 5, 7], 5) # multiple matches 4:5 julia> searchsorted([1, 2, 4, 5, 5, 7], 3) # no match, insert in the middle -3:2 +3:2 (empty range) julia> searchsorted([1, 2, 4, 5, 5, 7], 9) # no match, insert at end -7:6 +7:6 (empty range) julia> searchsorted([1, 2, 4, 5, 5, 7], 0) # no match, insert at start -1:0 +1:0 (empty range) julia> searchsorted([1=>"one", 2=>"two", 2=>"two", 4=>"four"], 2=>"two", by=first) # compare the keys of the pairs 2:3