esolang

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

Expected: Q

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
5Quit
4Store the time; this implementation stores 0, so every run is the same
3Read a byte into the cell, 0 at the end of the input
2Print the cell as a byte
1Nothing
0Set the accumulator to 1 and remember this place; if the cell is 0, jump past the next \|
-nGo 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

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 iag

Source

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