Handbook
Glossary
minmax ( seq -- min max )
Statistics
Prev:
range ( seq -- x )
Next:
kth-smallest ( seq k -- elt )
Vocabulary
math.statistics
Inputs
seq
a
sequence
Outputs
min
a
real
max
a
real
Word description
Finds the minimum and maximum elements of
seq
in one pass. Throws an error on an empty sequence.
Examples
USING: arrays math.statistics prettyprint ; { 1 2 3 } minmax 2array .
{ 1 3 }
Definition
USING:
kernel
math.order
sequences
;
IN:
math.statistics
:
minmax
( seq -- min max )
[
first
dup
]
keep
[
[
min
]
[
max
]
bi-curry
bi*
]
1
each-from
;