Skip to content

Common Instructions

Nic McPhee edited this page Apr 6, 2016 · 5 revisions

These instructions are registered for all types except auxiliary and tag.

name use input output

popper

pop the first item of the appropriate stack

$STACK

$STACK

duper

duplicate the first item of the appropriate stack

$STACK

$STACK

swapper

swap the first two items of the appropriate stack

$STACK

$STACK

rotter

rotate the first 3 items of the appropriate stack (1-2-3 to 3-1-2)

$STACK

$STACK

flusher

empty a given stack

$STACK

$STACK

eqer

compare the first two items of a stack

$STACK

:boolean

stackdepther

get the depth of a stack

$STACK

:integer

yank

yank one item to the top of a stack. The index is taken from the :integer stack; 0 is the top element of the stack, with indices increasing as you go down. If the specified stack happens to be the :integer stack, then the indexing begins after the index value is popped off the :integer stack. If the index is larger than the size of the specified stack, then the deepest element is `yank`ed up to the top.

:integer, $STACK

$STACK

yankdupe

similar to yank, but it copies to the top

:integer, $STACK

$STACK

shove

shoves an item down into a stack. The top item on the specified stack will be placed in slot i, where i is taken from the :integer stack, with everything at i and below being shoved down one position deeper on the stack; 0 is the top position, with indices increasing as you go down. If the specified stack happens to be the :integer stack, then the indexing begins after the index value is popped off the :integer stack. If the index is larger than the size of the specified stack, then the item is placed at the bottom of the stack.

:integer, $STACK

$STACK

Examples

yank

Initial state yank instruction Subsequent state

{:integer [2], :string ["a" "b" "c" "d"]}

string_yank

{:integer [], :string ["c" "a" "b" "d"]}

{:integer [2], :string ["a" "b" "c" "d"]}

integer_yank

{:integer [2], :string ["a" "b" "c" "d"]}

{:integer [87 2], :string ["a" "b" "c" "d"]}

string_yank

{:integer [2], :string ["d" "a" "b" "c"]}

{:integer [87 2], :string ["a" "b" "c" "d"]}

integer_yank

{:integer [2], :string ["a" "b" "c" "d"]}