iag
Three commands. The third one does six different things, and the accumulator decides which.
Panu Kalliokoski · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
iag was made by Panu Kalliokoski. It has a row of integer cells, an accumulator and only three commands. < moves left. = subtracts the cell from the accumulator, writes the result into both, and moves right. There is no way to move right without changing a cell, and no way to add.
Read the story
Everything else is |. What it does depends on the accumulator at that moment. It can print, read, quit, open a loop or close one. So a program spends most of its length steering the accumulator to the right number before each |.
The machine
Cells hold 32-bit signed integers and start at 0, as does the accumulator.
Accumulator at \| | Does |
|---|---|
| 5 | Quit |
| 4 | Store the time; this implementation stores 0, so every run is the same |
| 3 | Read a byte into the cell, 0 at the end of the input |
| 2 | Print the cell as a byte |
| 1 | Nothing |
| 0 | Set the accumulator to 1 and remember this place; if the cell is 0, jump past the next \| |
| -n | Go back to the place remembered n jumps ago, forget n places, set the accumulator to 0 |
A program almost always starts with ||. The accumulator is 0, so the first | makes it 1 and, since the cell is 0, skips the second. The debugging commands d and s of the reference are ignored.
Example
The first stretch of = and < brings the accumulator to 3 and reads Q into cell 4.
The first stretch of = and < brings the accumulator to 3 and reads Q into cell 4. The second brings it to 2 without touching cell 4, and ends on it, so the next | prints it. Try It Online's own Hello World for iag prints only H, and so does this one.
Further
Ideas it shows
See also
Unknown year
Write your own in Run Convert a program from iag
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: iag.
Command line
shib run iag -e '||===<<<====<<<===|<<==<<=<<===|x' --input 'Q'shib manual iagSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/iag.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org