Skip to content

rot

Input Stack:
...
second: Any
bottom: Any
Output Stack:
bottom: Any
...
second: Any

Rotate the stack so that the item at the bottom is moved to the top of the stack, and all other items move down one position. This is the opposite of :-rot.

Parameters

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

Examples

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

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