PlusOrMinus 2

From Esolang
Jump to navigation Jump to search

PlusOrMinus 2 is a fungeoid esolang created by User:PythonshellDebugwindow. It is a two-dimensional adaptation of PlusOrMinus.

Memory

Like PlusOrMinus, PlusOrMinus 2 uses an unsigned wrapping 8-bit accumulator which starts at zero.

Instruction pointer

PlusOrMinus 2 uses an instruction pointer which can travel up, right, down, or left. It starts at the top-left corner of the program, and is initially travelling to the right. If the instruction pointer goes out of bounds, then the program exits without raising an error.

Commands

Command Effect
+ Increments the accumulator.
- Outputs the Unicode character whose codepoint is equal to the value of the accumulator, then decrements the accumulator.
^ Makes the instruction pointer travel upwards.
> Makes the instruction pointer travel to the right.
V Makes the instruction pointer travel downwards.
< Makes the instruction pointer travel to the left.
| If the accumulator is equal to zero, then the instruction pointer begins travelling downwards.

All other characters, when encountered by the instruction pointer, cause the program to raise an error and exit.

Auto-formatting

Before execution of the program begins, each row will be truncated so that it is only as long as the shortest row; the same is true of columns. Trailing whitespace is ignored when finding the shortest row and column.

For example, the following program:

ABCDEFG
HIJKL M
NOPQRSTUV
 WX   Y
   Z

would be truncated to:

ABCD
HIJK
NOPQ

because the shortest row (   Z) is four characters long and the shortest column when trailing whitespace is ignored (AHM) is three characters long.

The lengths of the shortest row and column are calculated before truncation takes place. For example, the following program:

AB
C D
 E

would be truncated to:

AB
C 

with a trailing space on the second line.

Examples

Truth-machine

Replace the first + on the second line with > for input 0. Here, the code for input 1 is shown.

V                                                    V<<<
>+|>+++++++++++++++++++++++++++++++++++++++++++++++++>-+^
..>++++++++++++++++++++++++++++++++++++++++++++++++->>>>>

Resources