The Temporary Stack

From Esolang
Jump to navigation Jump to search

The Temporary Stack is a stack-based esoteric programming language created by User:PythonshellDebugwindow.

Instructions

Instructions are separated by spaces.

Instruction Meaning
@ Pushes to the stack the ASCII value of the each character of user input.
v Pushes to the stack the base-10 integer value of the number following this v (no space between this v and that number)
* Pushes to the stack the ASCII value of each character following this * (no space between this * and those character(s), and spaces can't be used - use v instead)
O Switches the output mode from ASCII value to base-10 integer value (the default)
o Inverse of O
+ Duplicates the top of the stack; the duplicate is added to the stack
: Repeats the next instruction until a value is either pushed to or removed from the stack (the next instruction still only counts as one command - see the bottom of the next section)
\ Repeats the next instruction until the stack is empty (the next instruction still only counts as one command - see the bottom of the next section)
Performs a random action (other than comment)
# Comment until space, which is command/comment separator (this comment counts as a command)

The v and * commands are just different ways of achieving the same result, but only v can be used to push spaces.

All other characters are treated as comments; however, if they are alone in a word, they still count toward the command count (e.g., the word unexecuted counts as a command). Note that such characters can appear within commands; for example, O, Others, and cOOde are equivalent, and v123 and hv1no2th3ing would both push the number 123.

The stack

The Temporary Stack has one way to store values (which must be integers): the stack. Each value has a "weight", which is just its value. Infinite values can be stored, but there is a catch: if the sum of all values' weights on the stack except for that of the bottom one, divided by two, is greater than the weight of the bottom value, then the bottom one gets "squished" and either the ASCII character of its value minus one, or just its value minus one, is output, depending on the output mode, which defaults to base-10 value and can be switched with "O" and "o". For example,

v1 v3

would output 0, and so would

v1 v1 v1 v1

because in both examples, the combined weights of all values in the stack except for the bottom one was 3, and that of the bottom value was 1, and since 3 divided by 2 is 1.5, which is greater than 1, the bottom value in the stack (1) was decremented by 1, removed from the stack, and output as a base-10 integer.

And as if that isn't hard enough, every fifteen commands, including comments, the stack is reset, hence the name "The Temporary Stack".

Examples

Hello, world!

o *Ifmmp-!xpsme" v11 v2297

Drunken cat

o @ \ @

Implementations