esolang

YABFD

Yet another brainfuck derivative, with portals to other tapes and cells that point at cells.

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

Tested with 3 known programs · Test method

Run it

Expected: aaaaaa

The idea

walksanator made YABFD after trying MineFuck, a Minecraft mod, and finding it slow. The name says what it is, Yet Another BrainFuck Derivative. It keeps the eight brainfuck commands and adds realms, which are separate tapes reached through a portal, a register called the pointer, cells that link to other cells, and if and else blocks. It holds all of brainfuck, so it is Turing complete.

Read the story

This implementation leaves out one command. _ runs a function that belongs to the realm, and the specification names none of them, so this implementation stops the run.

The machine

CommandDoes
+ - < > . , [ ]As in brainfuck, on byte cells that wrap
@ |Go to the realm the cell names, at its cell 0; write the realm's number
% *Put the cell's value or the cell's place in the pointer
$Write the pointer's value into the cell, or link the cell to its place
^Unlink the cell; it keeps the value it linked to
{c ... }Run the body if the condition c holds
( ... )Right after an if block, run when its condition did not hold

The conditions are 0 for a cell of 0, @ for a cell equal to the realm's number, * for a linked cell, and = < > to compare the cell before with this one. Every action on a linked cell lands on the cell it links to. This implementation makes a realm a ring of 30,000 cells; the specification only says realms are limited.

Example

The echo builds the letter a in cell 2, moves it to cell 0 through the pointer and reads a letter into cell 1.

The echo builds the letter a in cell 2, moves it to cell 0 through the pointer and reads a letter into cell 1. {= compares the two cells.

Expected: b

A link. Cell 1 holds A, * saves its place, and $ links cell 2 to it. The + on cell 2 raises cell 1, so both print B. After ^ cell 2 is a copy, and lowering it leaves cell 1 alone.

Expected: BBAB

The truth machine moves two cells left from cell 1, past the start of the tape, which works on a ring. On 0 it prints 0 once; on 1 it prints 1 forever.

Further

Ideas it shows

YABFD builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from YABFD

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run yabfd -e '+[-[---<]>>-]<- setup cell 2 to have the letter a
%[-]<<$ copy it to pointer then move it to cell 0
>, move to cell 1 and get input
{=......} if cells 0 and 1 are the same print the letter 6 times
(.) else print it once' --input 'a'
shib manual yabfd

Source

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

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

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