Cleave combinators

Factor handbook » The language » Combinators » Dataflow combinators

Factor handbook » The language » Combinators » Dataflow combinators

Prev: | Preserving combinators |

Next: | Spread combinators |

The cleave combinators apply multiple quotations to a single value or set of values.

Two quotations:

Three quotations:

An array of quotations:

Cleave combinators provide a more readable alternative to repeated applications of the keep combinators. The following example using keep:

can be more clearly written using tri:

Two quotations:

bi ( x p q -- )

2bi ( x y p q -- )

3bi ( x y z p q -- )

Three quotations:

tri ( x p q r -- )

2tri ( x y p q r -- )

3tri ( x y z p q r -- )

An array of quotations:

cleave ( x seq -- )

2cleave ( x y seq -- )

3cleave ( x y z seq -- )

4cleave ( w x y z seq -- )

Cleave combinators provide a more readable alternative to repeated applications of the keep combinators. The following example using keep:

[ 1 + ] keep
[ 1 - ] keep
2 *

can be more clearly written using tri:

[ 1 + ]
[ 1 - ]
[ 2 * ] tri

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2173, heads/master-f3ee5c5979, Sep 18 2022 13:17:51)