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

Prev:Cleave combinators
Next:Apply combinators


The spread combinators apply multiple quotations to multiple values. The asterisk (*) suffixed to these words' names signifies that they are spread combinators.

Two quotations:
bi* ( x y p q -- )

2bi* ( w x y z p q -- )


Three quotations:
tri* ( x y z p q r -- )

2tri* ( u v w x y z p q r -- )


An array of quotations:
spread ( objs... seq -- )


Spread combinators provide a more readable alternative to repeated applications of the dip combinators. The following example using dip:
[ [ 1 + ] dip 1 - ] dip 2 *

can be more clearly written using tri*:
[ 1 + ] [ 1 - ] [ 2 * ] tri*

A generalization of the above combinators to any number of quotations can be found in Combinators.