Skip to content

Commit 360b346

Browse files
committed
Name the output tuple elements (mn, mx)
1 parent 317548a commit 360b346

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

base/reduce.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,15 +763,17 @@ Inf
763763
minimum(a; kw...) = mapreduce(identity, min, a; kw...)
764764

765765
"""
766-
extrema(itr; [init]) -> Tuple
766+
extrema(itr; [init]) -> (mn, mx)
767767
768-
Compute both the minimum and maximum element in a single pass, and return them as a 2-tuple.
768+
Compute both the minimum `mn` and maximum `mx` element in a single pass, and return them
769+
as a 2-tuple.
769770
770771
The value returned for empty `itr` can be specified by `init`. It must be a 2-tuple whose
771772
first and second elements are neutral elements for `min` and `max` respectively
772773
(i.e. which are greater/less than or equal to any other element). It is used for non-empty
773-
collections. Note: it implies that, for empty `itr`, the first element is typically
774-
_greater_ than the last element. This is a "paradoxical" but yet expected result.
774+
collections. Note: it implies that, for empty `itr`, the returned value `(mn, mx)` satisfies
775+
`mn ≥ mx` even though for non-empty `itr` it satisfies `mn ≤ mx`. This is a "paradoxical"
776+
but yet expected result.
775777
776778
!!! compat "Julia 1.6"
777779
Keyword argument `init` requires Julia 1.6 or later.
@@ -791,16 +793,17 @@ julia> extrema([]; init = (Inf, -Inf))
791793
extrema(itr; kw...) = extrema(identity, itr; kw...)
792794

793795
"""
794-
extrema(f, itr; [init]) -> Tuple
796+
extrema(f, itr; [init]) -> (mn, mx)
795797
796-
Compute both the minimum and maximum of `f` applied to each element in `itr` and return
797-
them as a 2-tuple. Only one pass is made over `itr`.
798+
Compute both the minimum `mn` and maximum `mx` of `f` applied to each element in `itr` and
799+
return them as a 2-tuple. Only one pass is made over `itr`.
798800
799801
The value returned for empty `itr` can be specified by `init`. It must be a 2-tuple whose
800802
first and second elements are neutral elements for `min` and `max` respectively
801803
(i.e. which are greater/less than or equal to any other element). It is used for non-empty
802-
collections. Note: it implies that, for empty `itr`, the first element is typically
803-
_greater_ than the last element. This is a "paradoxical" but yet expected result.
804+
collections. Note: it implies that, for empty `itr`, the returned value `(mn, mx)` satisfies
805+
`mn ≥ mx` even though for non-empty `itr` it satisfies `mn ≤ mx`. This is a "paradoxical"
806+
but yet expected result.
804807
805808
!!! compat "Julia 1.2"
806809
This method requires Julia 1.2 or later.

0 commit comments

Comments
 (0)