monotonic? ( seq quot: ( elt1 elt2 -- ? ) -- ? )

Factor handbook » The language » Collections » Sequence operations » Groups and clumps

Factor handbook » The language » Collections » Sequence operations » Groups and clumps

Prev: | <circular-clumps> ( seq n -- clumps ) |

Next: | all-eq? ( seq -- ? ) |

Vocabulary

grouping

Inputs

Outputs

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:

Testing if a sequence is decreasing:

See also

all-eq?, all-equal?

Definition

grouping

Inputs

seq | a sequence |

quot | a 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

t

Testing if a sequence is decreasing:

USING: grouping math prettyprint ;
{ 9 8 6 7 } [ < ] monotonic? .

f

f

See also

all-eq?, all-equal?

Definition