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

Next:dupn ( n -- quot )


Vocabulary
generalizations

Inputs
nan integer


Outputs
None

Word description
A generalization of dup, 2dup and 3dup that can work for any number of items. The n topmost items on the stack will be copied and placed on the top of the stack.

Examples
USING: prettyprint generalizations kernel sequences.generalizations ; 1 2 3 4 4 ndup 8 narray .
{ 1 2 3 4 1 2 3 4 }

Some core words expressed in terms of ndup:
dup1 ndup
2dup2 ndup
3dup3 ndup


Definition