@@ -763,15 +763,17 @@ Inf
763
763
minimum (a; kw... ) = mapreduce (identity, min, a; kw... )
764
764
765
765
"""
766
- extrema(itr; [init]) -> Tuple
766
+ extrema(itr; [init]) -> (mn, mx)
767
767
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.
769
770
770
771
The value returned for empty `itr` can be specified by `init`. It must be a 2-tuple whose
771
772
first and second elements are neutral elements for `min` and `max` respectively
772
773
(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.
775
777
776
778
!!! compat "Julia 1.6"
777
779
Keyword argument `init` requires Julia 1.6 or later.
@@ -791,16 +793,17 @@ julia> extrema([]; init = (Inf, -Inf))
791
793
extrema (itr; kw... ) = extrema (identity, itr; kw... )
792
794
793
795
"""
794
- extrema(f, itr; [init]) -> Tuple
796
+ extrema(f, itr; [init]) -> (mn, mx)
795
797
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`.
798
800
799
801
The value returned for empty `itr` can be specified by `init`. It must be a 2-tuple whose
800
802
first and second elements are neutral elements for `min` and `max` respectively
801
803
(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.
804
807
805
808
!!! compat "Julia 1.2"
806
809
This method requires Julia 1.2 or later.
0 commit comments