2bi ( x y p q -- )
Factor handbook » The language » Combinators » Dataflow combinators » Cleave combinators

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


Vocabulary
kernel

Inputs
xan object
yan object
pa quotation with stack effect ( x y -- ... )
qa quotation with stack effect ( x y -- ... )


Outputs
None

Word description
Applies p to the two input values, then applies q to the two input values.

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

If [ p ] and [ q ] have stack effect ( x y -- z ), then the following two lines are equivalent:
[ p ] [ q ] 2bi 2dup p -rot q

In general, the following two lines are equivalent:
[ p ] [ q ] 2bi [ p ] 2keep q


Definition

: 2bi ( x y p q -- ) [ 2keep ] dip call ; inline