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

Prev:dupn ( n -- quot )
Next:nrot ( n -- quot )


Vocabulary
generalizations

Inputs
nan integer


Outputs
None

Word description
A generalization of dup, over and pick that can work for any stack depth. The nth item down the stack will be copied and placed on the top of the stack.

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

Some core words expressed in terms of npick:
dup1 npick
over2 npick
pick3 npick


Definition