PATH is one of the many esoteric programming languages. What
makes PATH different from Brain Fuck is the extra dimension it
allows. In brain fuck, you can only move forward in the
execution code. In PATH, you are allowed to move left, right,
up, and down the code where the code can be thought of as
stored in a matrix. Anyway, the commands for the language are
as follows:
$ - Start the program here,
heading right.
# - End the program.
+ - Increment the current memory cell.
- - Decrement the current memory cell.
} - Move to the next memory cell.
{ - Move to the previous memory cell.
, - Input an ASCII character from standard input into the current
memory cell.
. - Output an ASCII character from the current memory cell into
standard output.
/ - If heading in direction:
right, turn up
down, turn left
left, turn down
up, turn right
\ - If heading in direction:
right, turn down
down, turn right
left, turn up
up, turn left
^ - If the value of the current memory cell is not 0, turn up.
< - If the value of the current memory cell is not 0, turn left.
> - If the value of the current memory cell is not 0, turn right.
v - If the value of the current memory cell is not 0, turn down.
! - Jump over the next symbol.
(From Wikipedia)
For sake of interest, I also added in the following command:
: - Create another interpreter/thread. The newely created interpreter
will have a pointer that points to the same location as the
original one. There is no way to distinguish the original from
the newly created one. However, one thread moves up and the
other thread moves down, so you can assign different tasks to
them.
Below is a
PATH interpreter I wrote in Javascript. The numbers represents the
memory block. The numbers are colored red if there is a pointer
pointing at it.
The console is for output and a prompt will be created
for input. The delay is the time the interpreter waits befor
moving to the next command, so the lower the number the faster
it will run. You need to press process before running the code.