Skip to content

-rot

Input Stack:
top: Any
second: Any
...
Output Stack:
second: Any
...
top: Any

Rotate the stack so that the item at the top is moved to the bottom of the stack, and all other items move up one position.

Parameters

  • top: The item currently at the top of the stack that will be moved to the bottom
  • second: The item in the second position that will become the new top item
  • ...: Any additional items on the stack that will each move up one position

Examples

This example shows how the stack is rotated with four items:

a,b,c,d,:-rot
PosInputOutput
0 d c
1 c b
2 b a
3 a d
  • :rot - Rotate in the opposite direction (bottom to top)
  • :swap - Exchange the top two stack items
  • :over - Copy the second item to the top