An Eight-Instruction Turing-Complete Programming Language
The Language
Each program has access to two pieces of data:
- an array of 30000 integers, initially all set to zero
- an index into the array, called the pointer, initially set to zero
Both variables are implicit: the program never refers to them directly.
The language consists of eight commands, each of a single character:
-
>
Increment the pointer. -
<
Decrement the pointer. -
+
Increment the integer at the pointer. -
-
Decrement the integer at the pointer. -
.
Output the integer at the pointer. -
,
Input an integer into the slot at the pointer. -
[
If the integer at the pointer is zero, jump forward to the matching]
. -
]
If the integer at the pointer is not zero, jump backward to the matching[
.
Any other character in a program is ignored, including spaces.
The I/O operators work with ASCII values. For example, outputting a 65 prints a capital "A".
Some Programs
This program ,.
echoes one character from stdin back to stdout.
What do these programs do?
-
+++++++.
-
,[.,]
How about this one?
++ > +++++ [ < + > - ] < .