esolang

Brainfunct

Brainfuck with its loops taken out and numbered functions put in, called by the value in the cell.

Koen, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

Koen made Brainfunct in 2012, when he noticed how few brainfuck derivatives were functional. It keeps six of brainfuck's commands and drops [ and ]. In their place a program is a list of functions, and @ calls the function whose number is in the current cell.

Read the story

So a branch is a call through a number. A truth machine reads a digit and calls it: function 48 does nothing and function 49 prints a 1 and calls itself. A loop is a function that ends by calling itself. The specification shows that a Turing machine fits, one function for every pair of state and symbol.

The machine

CommandDoes
> <Move the pointer
+ -Change the cell by 1
. ,Print the cell as a character; read one into it
@Call the function numbered by the cell
/Ends a function; the part after the last one is the main program
( )A nested function, seen only inside the one around it

A function may start with its own number in octal. 61.@/,.@ is function 49, which is octal 61, followed by the main program; functions 1 to 48 do nothing.

Example

The last one is a cat.
Expected: 0
Expected: cat

The last one is a cat. It calls function 1, which reads a byte, prints it and calls function 1 again. The specification warns that it does not handle the end of the input, and it does not. It stops with an error when it tries to print the -1.

Further

Ideas it shows

Brainfunct builds on Brainfuck.

Functional paradigm

Brainfuck derivatives

Write your own in Run Convert a program from Brainfunct

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainfunct -e '61.@/,.@' --input '0'
shib manual brainfunct

Source

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

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

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