-
Notifications
You must be signed in to change notification settings - Fork 2
Commands
In these explanations, "the stack" refers to the current stack pointed to by the stack pointer.
i - Take in a line of input and push it, character by character, to the stack in the form of ASCII code points.
n - Take in a line of input as a raw number and push it to the stack.
o - Pop one number from the stack, turn it into the character with that ASCII value, and print it.
u - Pop one number from the stack, and print it.
r - Reverse the stack.
: - Duplicate the top value on the stack.
f - Flip the position of the two highest values on the stack.
! - Pop a number from the stack. If it is 0, push 1. Otherwise, push 0.
N - Pop a number from the stack and reverse its sign, e.g. 6 becomes -6 and vice-versa.
p - Pop a number from the stack.
> - Create another stack to the right of the current stack, or move to an existing one.
< - Create another stack to the left of the current stack, or move to an existing one.
y - Push the length of the stack to the stack.
a - Sort the stack from lowest to highest.
I - Pop a value off the stack, find the value on the stack with that index (Ly uses 0-indexing), and push it to the stack. If the index is out of range, an error is raised. e.g. [1, 2, 6, 4, 2] becomes [1, 2, 6, 4, 6].
~ - Pop a value off the stack. If that value can be found among the remaining stack values, push 1. Otherwise, push 0.
" - String literals; push the ASCII value of every character after the quote to the stack until another quote is met.
' - Character literals; push the next character to the stack.
0-9 - Digit literals; push the digit to the stack. Multi-digit numbers can be pushed if they are surrounded with parentheses.
+, -, *, /, % - Pop X and Y off the stack, then push Y operator X.
? - Pop X and Y off the stack, then push a random integer between Y and X.
=, G, L - Equals, greater than and less than, respectively. Pop a number off the stack, and push 1 if the top value on the stack ''operator'' that number and 0 otherwise.
c - Pop a number from the stack, and push the number of digits in that number.
S - Pop a number from the stack, and push each of its digits individually.
J - Pop the stack, and join it into a single number.
R - Pop X and Y from the stack, and push an inclusive range of values from Y to X to the stack.
` - Pop a value from the stack, and push that value plus one.
, - Pop a value from the stack, and push that value minus one.
[ - If the top of the stack is 0 or the stack is empty, skip the execution pointer to the corresponding ]. Otherwise, do nothing.
] - If the top of the stack is not 0 and the stack is not empty, move the execution pointer back to the corresponding [. Otherwise, do nothing.
$ - Pop a number from the stack and break out of that many layers of loops. Breaking out of a loop will place the execution pointer immediately after the end of the loop.
s - Save the top of the stack to the backup cell. This does not pop from the stack.
l - Take the current value of the backup cell, and push it to the stack. The backup cell will not lose its value.
; - End execution. This instruction is only required to end execution early; it is not required to add it at the end of every program.
Commands can be modified by placing a & symbol before them to make the instruction affect the entire stack instead of only the top value. This is the list of modifiable commands.
&+ - Push the sum of the stack. The stack will not be popped in this process.
&n - Write the entire input to the stack as numbers, in the correct order. Numbers are space-separated. (thus, an input of 23 53 54 would push [54, 53, 23] to the stack, from left to right)
&o - Pop the entire stack, and print it in the correct order.
&u - Pop the entire stack, and print it, as space-separated numbers, in the correct order.
&p - Pop the entire stack.
&: - Duplicate the entire stack on top of itself.
&s - Back up the whole stack to the backup cell. The stack will not be popped in this process.
l - The command to load in a backed up stack is the same as loading in a single value.