Shuffle words
Factor handbook ยป The language

Prev:Words
Next:Combinators


Shuffle words rearrange items at the top of the data stack as indicated by their stack effects. They provide simple data flow control between words. More complex data flow control is available with the Dataflow combinators and with Lexical variables.

Removing stack elements:
drop ( x -- )

2drop ( x y -- )

3drop ( x y z -- )

nip ( x y -- y )

2nip ( x y z -- z )


Duplicating stack elements:
dup ( x -- x x )

2dup ( x y -- x y x y )

3dup ( x y z -- x y z x y z )

over ( x y -- x y x )

2over ( x y z -- x y z x y )

pick ( x y z -- x y z x )


Permuting stack elements:
swap ( x y -- y x )


Duplicating stack elements deep in the stack:
dupd ( x y -- x x y )


Permuting stack elements deep in the stack:
swapd ( x y z -- y x z )

rot ( x y z -- y z x )

-rot ( x y z -- z x y )