esolang

Sad-Flak

Brain-Flak's brackets, but no loops. A line runs again and again until it jumps somewhere else.

Destructible-Watermelon · Turing complete: unknown · ●●● hard

Tested with 4 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: A

The idea

Sad-Flak mixes Brain-Flak with Woefully. Each line is one bracket expression. There is a line pointer, and a line keeps running while the pointer stays where it is; ≤x≥ moves the pointer x lines on, round the end of the program. Blank lines count for the pointer but are skipped when running, so a line below 32 blank lines runs 33 times while the pointer walks past them. A line holding just a number stands for that many blank lines.

The machine

Two stacks of unbounded integers, a and b, an empty stack popping 0. This implementation follows the Python interpreter in the repository Destructible-Watermelon/Sad-Flak, which is what TIO runs.

BracketDoes
()1
{}Pop a
[]Pop a; 1 if it was not 0, else 0
<>Move the top of a onto b, worth that value
(x)Push x onto a
[x]Minus x
{x}Pop b and multiply it by x
<x>Run x, worth 0
≤x≥Move the line pointer x lines on
≤≥Halt after this line

The input is integers, the first on top, or text after a leading ". At the end stack a is printed top first as characters, which is how TIO runs it with -A.

Example

In the second program the middle line sits after two blank lines.
Expected: A

In the second program the middle line sits after two blank lines. It adds 1 to the top and moves the pointer one line on, so it runs three times, at pointer 0, 1 and 2, before the pointer reaches the halt.

Patterns it teaches

Further

Also in Turing tarpits

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

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run sad-flak -e '≤≥' --input '"hi'
shib manual sad-flak

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/sad-flak.js

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