esolang

Mini-Flak

Brain-Flak with the second stack taken away, and still Turing complete.

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

Tested with 2 known programs · Test method

Run it

Expected: 6

The idea

Mini-Flak is a cut down Brain-Flak from 2016; the specification says Wheatwizard most likely made it. It keeps one stack, five bracket commands and the rule that every command gives a number. The stack holds integers of any size and starts as zeros all the way down. There is no second stack, no stack height and no input, and yet the language is Turing complete, by way of a counter machine.

The machine

CodeGivesDoes
()1
{}the popped valuepops
(x)the sum of xpushes that sum
[x]minus the sum of x
{x}the sum of every run of xruns x while the top is not 0

The specification leaves the output open. This implementation prints the final stack the way Brain-Flak does, top first, one number per line.

Example

(()()) is a (...) around two (), so it pushes 2.

(()()) is a (...) around two (), so it pushes 2. {{}} pops while the top is not 0; on three 2s it pops all three and gives 6, which the outer brackets push.

The swap. After pushing 2 and then 3 it leaves 2 on top of 3.

Expected: 2 3

The first part pushes the sum of both values and keeps the lower one. The second pushes the upper value and gives its negative, so the outer brackets push sum minus upper, which is the lower value.

Patterns it teaches

Further

Esoteric subset

Stack-based

Write your own in Run Convert a program from Mini-Flak

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: mini-flak.

Command line

shib run mini-flak -e '(()())'
shib manual mini-flak

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/mini-flak.js

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

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