Iterate
There are only loops. A number is how often a loop has been reached.
Aadenboy, 2025 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Aadenboy made Iterate in 2025. A program has no variables, only counted loops. The memory is in two places. One is the index of each running loop. The other is the number of times each loop or label has been visited, which goes up every time the loop is reached, even when it runs 0 times. So *?< (1*)<> > reads a number and visits the empty loop labelled 1 that many times, and =1 later reads the count back. Resetting a visit count is what makes the language Turing complete.
The machine
| Code | Means |
|---|---|
*5< ... > | Loop 5 times, index 1 to 5 |
(1*)5< ... > | The same, labelled 1 |
(*)1< ... > | The main loop, around the whole program |
? ~? %? | Amount read from the input as a number, a character, a byte |
n ~n = | Amount from the enclosing loop's index, passes left, visits |
n1 ~n1 =1 | The same for label 1 |
! & | Break, continue; !^ stops everything |
@ ~@ %@ | Print the loop's index as a number, a character, a byte |
$ $1 | Reset a visit count |
Example
The first is the A+B.
The first is the A+B. Label 1 is visited 3 and then 4 times. Loop 2 runs 7 times, skips every pass that still has passes left, and on the last one prints its index. The cat runs a loop as many times as the code of each character and prints the index of the last pass.
Further
Ideas it shows
See also
Also in Turing tarpits
Write your own in Run Convert a program from Iterate
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: iterate.
Command line
shib run iterate -e '(*)∞<
(1*)~?< // read a character
*~n< &1 > // skip forwards until the index equals the codepoint
~@ // output the character
&^ // continue past the break
>
! // if it was zero, there'\''s no more input and it stops executing
>' --input 'meow'shib manual iterateSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/iterate.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org