implicit loop brainfuck
Brainfuck without loops. The whole program is the loop, and the only branch is a skip.
Transoptimal · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Transoptimal made implicit loop brainfuck from one idea. The only conditional skips ahead, and a loop comes from running the whole program again and again until it halts.
Read the story
So [ and ] no longer match. [ jumps past the next ], not its partner, and only when the cell is 0. At the end of the code the program starts over, and a jump near the end can go past a ] near the start. Nothing stops a program but #. The specification says its examples were never run, as no implementation existed when it was written.
The machine
| Command | Does |
|---|---|
+ - < > . , | As in brainfuck |
[ | If the cell is 0, jump past the next ] |
{ | If the cell is not 0, jump past the next } |
] } | Nothing; they are only targets |
# | Halt |
"Next" looks on from the jump and round to the start of the program. Cells hold 0 to 255 and wrap, and the end of input reads as 0.
Example
The cat reads a character.
The cat reads a character. { skips the halt when it is not 0, . prints it, and the program starts over. At the end of input the cell is 0, so # runs.
The truth machine prints its input and takes 48 away. On 0 the cell is now 0 and # halts. On 1 it jumps over the halt, prints 1, and from then on the first { skips everything up to the same place, so it prints 1 forever.
The third counts. The first pass sets a counter of 5 and the letter A; every later pass starts with the counter not 0, so its { jumps past the setup. Each pass prints a letter and counts down, and {#} halts at 0. The {,}.-{# works the same way and prints every code from its input down to 1.
Patterns it teaches
- Turing tarpit: loops come from the program repeating and a skip.
See also
implicit loop brainfuck builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from implicit loop brainfuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: implicit-loop-brainfuck.
Command line
shib run implicit-loop-brainfuck -e ',{#}.' --input 'hello'shib manual implicit-loop-brainfuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/implicit-loop-brainfuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org