dip ( x quot -- x )
Factor handbook » The language » Combinators » Dataflow combinators » Preserving combinators

Next:2dip ( x y quot -- x y )


Vocabulary
kernel

Inputs
xan object
quota quotation


Outputs
xan object


Word description
Removes x from the datastack, calls quot, and restores x to the top of the datastack when quot is finished.

Examples
USING: arrays kernel math prettyprint ; 10 20 30 [ / ] dip 2array .
{ 1/2 30 }


Notes
dip is executed as a primitive when preceded by a literal quotation. The below definition is not executed unless its argument is a non-literal quotation, such as a quotation constructed with curry or compose, or for Fried quotations or quotations including Lexical variables.

Definition

: dip ( x quot -- x ) swap [ call ] dip ;