ndip ( n -- )
Factor handbook » The language » Combinators » Generalized shuffle words and combinators » Generalized combinators

Next:nkeep ( n -- )


Vocabulary
generalizations

Inputs
nan 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 }

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

Some core words expressed in terms of ndip:
dip1 ndip
2dip2 ndip
3dip3 ndip


Definition