maximum-by ( ... seq quot: ( ... elt -- ... x ) -- ... elt )
Factor handbook » The language » Collections » Sequence operations » Sequence combinators

Prev:maximum ( seq -- elt )
Next:shorter ( seq1 seq2 -- seq )


Vocabulary
sequences

Inputs
seqa sequence
quota quotation


Outputs
eltan object


Word description
Outputs the greatest element of seq according to the quot.

Examples
Example:
USING: sequences prettyprint ; { { 1 2 } { 1 2 3 } { 1 2 3 4 } } [ length ] maximum-by .
{ 1 2 3 4 }


Errors
Throws an error if the sequence is empty.

See also
min, max, minimum, minimum-by, maximum

Definition


: maximum-by
( ... seq quot: ( ... elt -- ... x ) -- ... elt )
[ after? ] select-by ; inline