esolang

Brainfucker

Brainfuck on a plane of numbers that never wrap. It can square a cell, but it cannot print a letter.

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

Tested with 4 known programs · Test method

Run it

Expected: 123

The idea

Brainfucker appeared in 2024, after brainfuck. Its memory is a plane without edges, and each cell holds a whole number of any size and either sign. Two more arrows move the pointer up and down, * squares the cell and / takes its square root. Input and output are numbers only, so the first example in the specification prints 123 and calls Hello World impossible.

The machine

CommandDoes
> <Move the pointer right or left
^ vMove the pointer up or down
+ -Add or take away 1
* /Square the cell; take its square root
. ,Print the cell as a number; read a number
[ ]Loop while the cell is not 0

The specification leaves some things open. In this implementation / keeps the whole part of the root, and the root of a negative number is an error. Printed numbers go one to a line. , reads the next whole number in the input, and 0 when there is none. Every other character is a comment.

Example

The 123 program.

The 123 program. Three ones make 3, which squares to 9. Two more make 11, which squares to 121, and two more make 123.

The series of squares. A counter of 6 sits in the first cell. The cell above it prints 1 and 2, and then each turn of the loop squares it and prints it, six times. The last number has 20 digits.

Expected: 1 2 4 16 256 65536 4294967296 18446744073709551616

The numeric cat stops at the first 0. Its truth machine prints 0 once, or 1 forever.

Expected: 5 -3 12
Expected: 0

Patterns it teaches

  • Turing tarpit: all of brainfuck, with a plane for memory and numbers without bounds.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Brainfucker

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainfucker -e ',[.,]' --input '5 -3 12 0'
shib manual brainfucker

Source

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

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

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