Number2D

From Esolang
Jump to navigation Jump to search

Number2D is esoteric programming language by User:ChuckEsoteric08 that uses ONLY numbers!

Commands

Command Description
1 If the current direction is right, set it to down; if it is left, set it to up; If down, set it to right; if up, set it to left.
2 If the current direction is right or down, set it to left; otherwise, if left or up, set it to right.
3 Flip the current bit and move the cell pointer one step right.
4 Move the cell pointer one step left.
5 If the current bit equals 0, skip the next instruction.
6 Gather the next 8 bits, commencing from that under the cell pointer, interpret these as an unsigned byte value, the current cell value furnishing the most significant bit (MSB), and output the character whose ASCII code corresponds to the same.
0 Immediately stop the program.

If the instruction pointer (IP) is outside of the program's bounds, then wrap its trajectory around and continue from the opposite side.

Examples

Example 1

1
21
 0

It will set the direction to down, set the direction to left, then up. Because the IP is outside of the program, it moves back from the down side, then the program stops.

Example 2

This shows how to make control program flow:

3510
  4
  3
  0

It flips a bit and moves the cell pointer to the right. Because the bit is zero, the direction is not set downwards, hence the program halts.

Let's add 4 after 3

34510
   4
   3
   0

It flips a bit and moves pointer to the right. Then it sets the direction to down, because current bit is not 0. It will move pointer to the left and flip it, then the program stops.

H

Outputs "H"

334334333433433434444444460

Computational class

It is Turing-complete, because you can translate it to BitChanger, but with output

BitChanger Number2D
} 3
[ and ] Changing directions. Example of it above
< 4

Interpreter

  • Common Lisp implementation of the Number2D programming language.