Handbook
Glossary
kth-smallest ( seq k -- elt )
Statistics
Prev:
minmax ( seq -- min max )
Next:
Computing histograms
Vocabulary
math
.
statistics
Inputs
seq
a
sequence
k
an
integer
Outputs
elt
an
object
Word description
Returns the kth smallest element. This is semantically equivalent to
swap natural-sort nth
, and is therefore zero-indexed.
k
may not be larger than the highest index of
sequence
.
Examples
USING: math.statistics prettyprint ; { 3 1 2 } 1 kth-smallest .
2
Definition
USING:
math
math.statistics.private
;
IN:
math.statistics
:
kth-smallest
( seq k -- elt )
[
<
]
kth-object-unsafe
;