Skip to content

over

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

Copy the item in the second position on the stack to the top, leaving the original item in place. This allows you to access an item that's buried under the top item without losing the top item.

Parameters

  • top: The item currently at the top of the stack (remains in place)
  • second: The item in the second position that will be copied to the top

Examples

Basic over operation:

a,b,:over
PosInputOutput
0 b a
1 a b
2 a

Common pattern - apply the same operation to two different expressions:

name,cpu,:eq,
:sum,
name,memory,:eq,
:sum,
:over,
:add
  • :dup - Duplicate the top item
  • :swap - Exchange the top two items
  • :tuck - Copy the top item to the third position
  • :rot - Rotate three items (bottom to top)