monotonic? ( seq quot: ( elt1 elt2 -- ? ) -- ? )
Factor handbook » The language » Collections » Sequence operations » Groups and clumps

Prev:<circular-clumps> ( seq n -- clumps )
Next:all-eq? ( seq -- ? )


Vocabulary
grouping

Inputs
seqa sequence
quota quotation with stack effect ( elt1 elt2 -- ? )


Outputs
?a boolean


Word description
Applies the relation to successive pairs of elements in the sequence, testing for a truth value. The relation should be a transitive relation, such as a total order or an equality relation.

Examples
Testing if a sequence is non-decreasing:
USING: grouping math prettyprint ; { 1 1 2 } [ <= ] monotonic? .
t

Testing if a sequence is decreasing:
USING: grouping math prettyprint ; { 9 8 6 7 } [ < ] monotonic? .
f


See also
all-eq?, all-equal?

Definition