_

From Esolang
Jump to navigation Jump to search
The title of this article is not correct because of technical limitations. The correct title is actually _.

_ is an esolang by User:PythonshellDebugwindow.

Commands

Command Effect
% Pop a character from the end of the source code
$ Pop a character from the end of the source code and set the next character in the source to the popped character
^ Skip the next command if the last character in the source code is 0
\ Append the next character to the end of the source code and skip it
Anything else Append the character to the end of the source code

Examples

Infinite loop

0

Truth-machine

Replace 1 with 0 for input 0.

^1

Computational class

_ is a finite-state automaton.

Let's take the instruction pointer's distance away from the end of the program (i.e. the amount of commands left to run) over the course of a program's execution, and call it k. A program begins with k as the program's length, and the program halts when k hits 0 (or less, in cases such as % being the final instruction). The infinite loop always has a k of 1. Note that only the last k commands of a program matter, since there's no way to access commands that the instruction pointer has already passed.

Now let's consider how each instruction affects k. In each snippet, the last k commands of a program are underlined, i.e. the instruction pointer is at the first underlined command.

% $ ^ (skip) ^ (no skip) \ Anything else
...%...x ...$x...y ...^x...0 ...^x...1 ...\x... ...x...
...%... ...$y... ...^x...0 ...^x...1 ...\x...x ...x...x
kk-2 kk-2 kk-2 kk-1 kk-1 kk

Notice that k never increases during the course of the program.

Since every non-command other than 0 cannot be distinguished by the program, a program with a certain k is restricted to one of 6k+6k-1+6k-2+...+62+61+60 states for the rest of its execution. Since a program can only start with a finite k, every _ program must be able to be simulated using only a finite amount of states.

External resources