PlusOrMinus 2

From Esolang
Jump to navigation Jump to search

PlusOrMinus 2 (POM2) is an fungeoid esolang by User:PythonshellDebugwindow. It is a 2D version of PlusOrMinus (POM).

Memory

Like POM, POM2 uses an unsigned 8-bit accumulator.

Instruction Pointer

POM2 uses an IP that can at any one time be going either UP, RIGHT, DOWN, or LEFT. If the IP goes out-of-bounds, then the program exits without an error.

Commands

Command Meaning
+ Increment the accumulator
- Output the (extended) ASCII character of the accumulator, then decrement it
^ Set the IP's direction to UP
> Set the IP's direction to RIGHT
V Set the IP's direction to DOWN
< Set the IP's direction to LEFT
| If the accumulator is equal to 0, set the IP's direction to DOWN

All other characters, when encountered by the IP, cause the program to error and exit.

Auto-formatting

All rows and columns will be cut off to match the shortest one. So this code:

ABCDEFG
HIJKL
MNOPQRSTUV
 WX    Y
  Z

would become:

ABC
HIJ
MNO

because the shortest row ( Z) has 5 characters and the shortest column (AHM) has 3 characters, so the code becomes a 5x3 version of itself. The extra rows will be cut off first:

ABC
HIJ
MNO
 WX
  Z

Then the extra columns (maybe unnecessary):

ABC
HIJ
MNO
 WX
  Z

The gods of POM2 themselves must have told me how to write the function that performs this task, as I am not entirely sure of its results 100% of the time, yet it works.

Examples

Truth-machine

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

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

Resources

  • An interpreter written in Python (the source code is full of commented out print tests), along with some examples