esolang

Malbrain

Brainfuck with two commands. One moves to the next command, the other writes it.

Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: cat

The idea

Malbrain is brainfuck behind a dial. The eight brainfuck commands stand in a fixed circle, and a pointer starts on the first. > turns the dial one step and . writes the command it points at. The dial stays where it is after a ., so every command depends on the one before. The specification calls that extremely hard to maintain.

Read the story

Under it the program is plain brainfuck, so Malbrain can compute whatever brainfuck can.

The machine

NumberCommand
0>
1<
2+
3-
4.
5,
6[
7]

> after 7 comes back to 0. Every other character is a comment. The brainfuck runs on byte cells that wrap, on a tape with no end either way, and , leaves the cell as it was at the end of the input, as the cat expects.

Example

The cat is ,[.[-],].
Expected: 0

The cat is ,[.[-],]. Five > reach ,, one more reaches [, and six more go round the circle to .. The second is the truth machine ,.[-->+[>>]<[.]<<]. On 1 it prints 1 for ever.

The Hello World is 321 commands on six lines, 180 > and 141 ., for 141 commands of brainfuck.

Expected: Hello World!

Patterns it teaches

Further

Malbrain builds on Brainfuck.

Turning tarpits

Brainfuck derivatives

Write your own in Run Convert a program from Malbrain

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: malbrain.

Command line

shib run malbrain -e '>>>>>.>.>>>>>>.>>.>>>>>.>>>>.>>>>>>.>>.' --input 'cat'
shib manual malbrain

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/malbrain.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org