esolang

brainappend

A loop that cannot jump back, so it copies itself onto the end of the program instead.

Joaozin003, 2023 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: cat

The idea

Joaozin003 made brainappend in 2023, partly after Vague. It is brainfuck, except that ] never jumps back. When the cell is not 0, ] takes the text from its matching [ to itself, both brackets included, and appends it to the end of the program. The run goes on past the ] and meets the copy later, after the rest of the program.

Read the story

So a loop only repeats straight away when it stands last, where its copies follow each other. A loop in the middle runs its body once on the spot, and its repeats wait at the end.

The machine

CommandDoes
+ - < >Brainfuck's, on bytes that wrap
. ,Print the cell; read a byte into it
[Jump past the matching ] if the cell is 0
]If the cell is not 0, append the loop to the program

The run ends when it passes the end of the program as it is by then. This implementation follows the Common Lisp interpreter in the specification, where a line feed and the end of the input both read as 0.

Example

The cat reads a byte and enters the loop while it is not 0.
Expected: 0

The cat reads a byte and enters the loop while it is not 0. Each ] appends a fresh [.,], and the run steps straight into it. At the end of the input the cell is 0, no copy is made and the program runs out.

The truth-machine prints its input, then puts 49 in the next cell and takes 48 off the input. On 0 the loop is skipped. On 1 every pass prints a 1 and appends one more pass.

Patterns it teaches

Further

brainappend builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from brainappend

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainappend -e ',[.,]' --input 'cat'
shib manual brainappend

Source

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

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

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