npick ( n -- quot )

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

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

Prev: | dupn ( n -- quot ) |

Next: | nrot ( n -- quot ) |

Vocabulary

generalizations

Inputs

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

Some core words expressed in terms of npick:

Definition

generalizations

Inputs

n | an 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 }

{ 1 2 3 4 1 }

Some core words expressed in terms of npick:

dup | 1 npick |

over | 2 npick |

pick | 3 npick |

Definition