GOTO 10
Only GOTO, run by crowds of threads, and the size of the crowd that reaches line 0 is the output.
2015 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
GOTO 10 is from 2015. Every line is a line number and a GOTO. Execution starts on the lines numbered 10, and every step each line with threads on it runs once, all at the same time. There are no variables. What a program knows is how many threads stand on each line.
Read the story
A line can send its threads somewhere else, and WITH says how many go. If two lines share a number, a thread that jumps there forks into both. Threads that jump to a number no line has die, and the run ends when none are left.
The machine
| Part | Means |
|---|---|
10 GOTO 20 | Send this line's threads to line 20 |
WITH e | Send e threads instead |
I I(x) | The next input bit, or the next x bits as a number |
N N(x) | The threads on this line, or those that came from line x |
+ - * / ( ) | Whole number arithmetic |
REM | A comment |
Line 0 is the output. When n threads jump to line 0 in a step, n minus 1 is written out as bits, the lowest bit first. Eight bits make a byte. At the end of the input I is minus 1, so WITH I+1 sends no threads at all.
Example
The Hello world.
The Hello world. One line 10 sends 6379151218083139189807317952019 threads to line 0, which writes the first 103 of the text's 104 bits. The last bit is a 0, and a number cannot end in a 0 bit. So the other line 10 sends one thread to line 20, which sends it on to line 0 a step later, and 1 minus 1 writes that last 0.
A cat program. Both lines read the same bit, as they run together. The first sends 1 or 2 threads to line 0, which writes the bit, and the second keeps both lines alive until the input runs out.
Patterns it teaches
- One instruction: GOTO is all there is.
- Counter machines: the number of threads on a line is the only memory.
- Encoding tricks: a whole text is one number of threads.
Further
See also
Also in Strange time
Write your own in Run Convert a program from GOTO 10
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: goto-10.
Command line
shib run goto-10 -e '10 GOTO 0 WITH I+1
10 GOTO 10 WITH I+1' --input 'cat'shib manual goto-10Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/goto-10.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org