Infinite Goto
Every line is a jump. What happens depends on where you land.
PythonshellDebugwindow, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
PythonshellDebugwindow made Infinite Goto in 2020. A program is a column of integers, and the integer on a line is the number of the line to jump to next. Nothing is written as an instruction. The work is done by the line numbers themselves, so a program is a choice of where to jump.
Read the story
There is no way to stop. The programs run until they are stopped from outside, and a run ends when it asks for a line of input that is not there.
The machine
There are 45 cells of unbounded size and a cell pointer at cell 0. Arriving at a line does what its number modulo 45 says.
| Line | Does |
|---|---|
| 5 | Read a line into the cell; anything but a whole number reads as 0 |
| 16 | Print the cell and a line feed |
| 19 | Go on to line 20 if the cell is above 0, else to line 21 |
| 27 | Go on to one of lines 28 to 32 at random |
| 35 | Point at the cell numbered by the line it came from, modulo 45 |
| other even lines | Add 1 to the cell, except 0, 20, 28, 30 and 32 |
| other odd lines | Take 1 from the cell if it is above 0, except 21, 29 and 31 |
A line that holds anything but an integer is invalid. Jumping there passes on to the line below it, without its effect. Jumps below 0 go to line 0 and jumps past the end go to the last line. With an increment, a decrement that stops at 0 and a test for 0, the cells are a counter machine.
Example
The numeric cat.
The numeric cat. Line 0 jumps to line 5, which reads, and line 5 jumps to line 16, which prints and jumps back to line 5. The other lines are only there to number lines 5 and 16.
A countdown. Line 19 tests the cell, line 20 jumps to 16 to print it, and line 16 jumps to line 1, an odd line, which takes 1 off. At 0 line 19 sends it to line 21, which reads again and so ends the run.
Patterns it teaches
- Counter machines: 45 counters, each line an increment, a decrement or a test.
- Turing tarpit: a program holds nothing but jump targets.
Further
See also
Cell-based
Write your own in Run Convert a program from Infinite Goto
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: infinite-goto.
Command line
shib run infinite-goto -e '5
-1
-2
-3
-4
16
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
5' --input '5
'shib manual infinite-gotoSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/infinite-goto.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org