Inverted
Brainfuck in words, read from the bottom up, where every word means its opposite.
Dominicentek, 2021 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Dominicentek wrote Inverted in Java in 2021. It is brainfuck with each command as a word on its own line, and everything turned around. The program runs from its last line to its first. inc takes 1 away, dec adds 1, left moves right and right moves left. A loop is written with end above while, since the bottom comes first.
Read the story
The specification gives two converters in JavaScript, Inverted to brainfuck and back. They reverse the lines and swap each word for its brainfuck character.
The machine
There are 100 cells of signed 32-bit integers.
| Word | Does | Brainfuck |
|---|---|---|
dec inc | Add 1, take 1 | + - |
left right | Move right, move left | > < |
while ... end | Repeat while the cell is not 0 | [ ] |
text | Print the cell as a character | . |
char | Read a character | , |
if ... end | Run once if the cell is not 0 | |
loop ... end | Run as many times as the cell says | |
print user | Print or read a number | |
random | A number from 0 to the cell minus 1 | |
exit | Stop |
Example
The truth machine from the specification reads a number, and while it is not 0 prints it.
The truth machine from the specification reads a number, and while it is not 0 prints it. Then it prints it once more. On 0 that is a single 0; on 1 it never stops.
A countdown. Read from the bottom, it adds 3 and then prints and takes 1 until the cell is 0.
The Hello World is 153 lines. Its converter turns it into a brainfuck program of the same length that prints Hello World! and a line feed.
Patterns it teaches
- Turing tarpit: brainfuck's eight commands, with a few more.
- Encoding tricks: the same brainfuck, spelled in words and upside down.
Further
See also
Inverted builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Inverted
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: inverted.
Command line
shib run inverted -e 'print
end
print
while
user' --input '0'shib manual invertedSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/inverted.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org