/gɹəʊguː/
Two registers, a loop that makes the program longer every time round, and a command that prints the words no output.
PythonshellDebugwindow, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
PythonshellDebugwindow made /gɹəʊguː/ in 2020. It has two registers of any size, nr and dm, both 0 at the start. The loop is ], which jumps back to just after the nearest [. But [ is a command as well, and it prints [no output]. So a loop has to step over its own [ the first time, with !, which skips the next command when nr is below 0. Each time ] jumps, it also puts one more [ on the end of the program.
Read the story
Printing is odd too. , prints half of nr, rounded down, so a program doubles a number with + before it prints it.
The machine
| Char | Does |
|---|---|
[ | Print [no output] |
] | Put a [ on the end, then jump to just after the nearest [ before it, or to the start |
; | Read an integer into nr, or 0 if the input is not one |
&d | Add the digit d to nr |
< | Take 1 from nr |
+ - | Add nr to itself; take it from itself, which leaves 0 |
! | Skip the next command if nr is below 0 |
, | Print nr divided by 2, rounded down |
{ } | Copy nr to dm; copy dm to nr |
? | Halt |
The specification leaves the output format open. In this implementation each output ends with a line feed.
Example
The truth machine keeps the input in dm and makes nr -1, so ! skips the [.
The truth machine keeps the input in dm and makes nr -1, so ! skips the [. It prints the input and takes 1 from it. On 0 that leaves -1, ! skips the ] and ? halts. On 1 it leaves 0, and ] jumps back to print 1 again, forever.
The countdown prints from its input down to 0. The integer cat stops at the first number that is not positive.
Patterns it teaches
- Self-modifying code: every jump back adds a
[to the end of the program.
Further
See also
Also in Hostile
Write your own in Run Convert a program from /gɹəʊguː/
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: g-gu.
Command line
shib run g-gu -e ';{-<![}+,}<!]?' --input '0'shib manual g-guSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/g-gu.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org