Compositional combinators
Factor handbook » The language » Combinators

Prev:Looping combinators
Next:Short-circuit combinators


Certain combinators transform quotations to produce a new quotation.
Examples of compositional combinator usage

Fundamental operations:
curry ( obj quot -- curry )

compose ( quot1 quot2 -- compose )


Derived operations:
2curry ( obj1 obj2 quot -- curried )

3curry ( obj1 obj2 obj3 quot -- curried )

with ( param obj quot -- obj curried )

prepose ( quot1 quot2 -- composed )


These operations run in constant time, and in many cases are optimized out altogether by the Optimizing compiler. Fried quotations are an abstraction built on top of these operations, and code that uses this abstraction is often clearer than direct calls to the above words.

Curried dataflow combinators can be used to build more complex dataflow by combining cleave, spread and apply patterns in various ways.
Curried dataflow combinators

Quotations also implement the sequence protocol, and can be manipulated with sequence words; see Quotations. However, such runtime quotation manipulation will not be optimized by the optimizing compiler.