extrema

Returns an array of the minimum and maximum element in r. Performs < 3n/2 comparisons, unlike the naive < 2n.

ElementType!Range[2]
extrema
(
Range
)
(
Range r
)
if (
isInputRange!Range &&
!isInfinite!Range
)

Parameters

r Range

The range to traverse.

Examples

assert(extrema([5,2,9,4,1]) == [1, 9]);

Meta