PATH

From Esolang
Jump to: navigation, search

PATH, invented by Francis Rogers in August 2003, is a two-dimensional language inspired by Brainfuck and Befunge. PATH's environment, like Brainfuck's, consists of an array of memory cells all initialized to zero and character-based standard input and output. PATH understands the following commands:

Command Explanation
$
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.

As in Brainfuck, any character not understood as a command is simply skipped over.

Computational class[edit]

We can show how to convert any Brainfuck program into an equivalent PATH program, and in this way, show that PATH is in the same computational class as Brainfuck (i.e. that it is Turing-complete).

Consider the following trivial Brainfuck program:

+[>-<-]

+ and - remain unchanged. < and > become { and } respectively. Finally, each [] loop can be coded idiomatically, using !/\v commands. This is spaced out for clarity in the following example:

   / v          \
+  /!\  }-{-  v!\
   \          /

Variations[edit]

Some implementations have added ] and [ to unconditionally direct the flow of the program right or left, but the PATH author has requested these implementors give their variants different names.

Languages based on PATH include SNUSP, which is more orthogonal and optionally supports advanced features, and LNUSP, which uses only 5 commands and supports diagonal control flow.

External resources[edit]