esolang

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

Expected: 0

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.

WordDoesBrainfuck
dec incAdd 1, take 1+ -
left rightMove right, move left> <
while ... endRepeat while the cell is not 0[ ]
textPrint the cell as a character.
charRead a character,
if ... endRun once if the cell is not 0
loop ... endRun as many times as the cell says
print userPrint or read a number
randomA number from 0 to the cell minus 1
exitStop

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.

Expected: 321

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

Further

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 inverted

Source

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