esolang

Brainfish

brainfuck's tape and loops, with Deadfish's four commands working the cell under the pointer.

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

Tested with 3 known programs · Test method

Run it

Expected: hi

The idea

Brainfish is a cross between brainfuck and Deadfish. It keeps six of brainfuck's eight commands, the moves, the loop and character input and output. It drops + and - and takes Deadfish's i, d, s and o in their place. Each of those works on the cell at the pointer, not on one accumulator.

Read the story

So i and d are brainfuck's + and - under other names, and the language can do all that brainfuck can. What it adds is s, which squares a cell, and o, which prints a cell as a number.

The machine

CommandDoes
> <Move the pointer right or left
[ ]Skip the loop when the cell is 0; go back while it is not
, .Read a character's code; print the character with the cell's code
i dAdd 1 to the cell or take 1 from it
sSquare the cell
oPrint the cell as a number

Cells hold whole numbers without a bound, and there is no Deadfish reset at 256. o prints the digits alone, and , stores 0 at the end of the input.

Example

The hi program.

The hi program. Ten rounds put 10 into the third cell each time, so it holds 100. Four more make 104, an h, and one more makes 105, an i.

The cat reads one character and prints its code.

Expected: 65

Squaring twice takes 2 to 16.

Expected: 16

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Brainfish

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainfish -e ',o' --input 'A'
shib manual brainfish

Source

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

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

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