Stable

From Esolang
Jump to navigation Jump to search

Stable is an esoteric programming language that can push only zeroes. The only way to get nonzero number is to preserve the initial stack. This language is inspired by Volatile. This language can be interpreted as deterministic subset of Volatile with initial stack of [1], instead of empty stack.

Notation

We use {stack}{program} notation. We also use <variable> for denoting variable. (...) is a single token that can be deconstructed to get its contents. Additionally, we use word "error" if the program errors. Output is indicated with output: clause after the rule.

Original State

The original state of the program is:

{1}{<program>}

Instruction

The instructions are the same as Volatile, but without ~. Rule above is favored over the bottom ones.

{<stack> a b}{+ <program>}      => {<stack> a+b} {<program>}
{<stack> a b}{- <program>}      => {<stack> a-b} {<program>}
{<stack> a b}{* <program>}      => {<stack> a*b} {<program>}
{<stack> a 0}{/ <program>}      => error
{<stack> a b}{/ <program>}      => {<stack> a/b} {<program>}
{<stack> a}{: <program>}        => {<stack> a a} {<program>}
{<stack> a}{. <program>}        => {<stack> a} {<program>} output: a
{<stack> 0}{(<loop>) <program>} => {<stack> 0} {<program>}
{<stack> a}{(<loop>) <program>} => {<stack> a} {<loop> (<loop>) <program>}
{<stack>}{<program>}            => error

See also