tri ( x p q r -- )

Factor handbook » The language » Combinators » Dataflow combinators » Cleave combinators

Factor handbook » The language » Combinators » Dataflow combinators » Cleave combinators

Prev: | 3bi ( x y z p q -- ) |

Next: | 2tri ( x y p q r -- ) |

Vocabulary

kernel

Inputs

Outputs

None

Word description

Applies p to x, then applies q to x, and finally applies r to x.

Examples

If [ p ], [ q ] and [ r ] have stack effect ( x -- ), then the following two lines are equivalent:

If [ p ], [ q ] and [ r ] have stack effect ( x -- y ), then the following two lines are equivalent:

In general, the following two lines are equivalent:

See also

bi, cleave

Definition

kernel

Inputs

x | an object |

p | a quotation with stack effect ( x -- ... ) |

q | a quotation with stack effect ( x -- ... ) |

r | a quotation with stack effect ( x -- ... ) |

Outputs

None

Word description

Applies p to x, then applies q to x, and finally applies r to x.

Examples

If [ p ], [ q ] and [ r ] have stack effect ( x -- ), then the following two lines are equivalent:

[ p ] [ q ] [ r ] tri
dup p dup q r

If [ p ], [ q ] and [ r ] have stack effect ( x -- y ), then the following two lines are equivalent:

[ p ] [ q ] [ r ] tri
dup p over q rot r

In general, the following two lines are equivalent:

[ p ] [ q ] [ r ] tri
[ p ] keep [ q ] keep r

See also

bi, cleave

Definition