ndip ( n -- )

Factor handbook » The language » Combinators » Generalized shuffle words and combinators » Generalized combinators

Factor handbook » The language » Combinators » Generalized shuffle words and combinators » Generalized combinators

Next: | nkeep ( n -- ) |

Vocabulary

generalizations

Inputs

Outputs

None

Word description

A generalization of dip that can work for any stack depth. The quotation will be called with a stack that has 'n' items removed first. The 'n' items are then put back on the stack. The quotation can consume and produce any number of items.

Examples

Some core words expressed in terms of ndip:

Definition

generalizations

Inputs

n | an integer |

Outputs

None

Word description

A generalization of dip that can work for any stack depth. The quotation will be called with a stack that has 'n' items removed first. The 'n' items are then put back on the stack. The quotation can consume and produce any number of items.

Examples

USING: arrays generalizations kernel prettyprint ;
1 2 [ dup ] 1 ndip 3array .

{ 1 1 2 }

{ 1 1 2 }

USING: arrays generalizations kernel prettyprint ;
1 2 3 [ drop ] 2 ndip 2array .

{ 2 3 }

{ 2 3 }

Some core words expressed in terms of ndip:

dip | 1 ndip |

2dip | 2 ndip |

3dip | 3 ndip |

Definition