Conditional brainfuck

From Esolang
Jump to navigation Jump to search

Conditional brainfuck (CBF) is a brainfuck variant discovered by User:Orby in May of 2020.

Model

CBF uses a tape of n-bit wrapping cells which is unbounded on the right. There is a tape head which points at one cell at a time. CBF programs run in an implicit loop.

Commands

CBF uses five commands. The conditional structure {} replaces the looping structure [] found in brainfuck. Input and output are optional and not specified as part of the language standard.

Command Description
+ Increment the current cell
- Decrement the current cell
> Shift the tape head right
< Shift the tape head left
{ If the current cell is zero, jump to the first instruction after the matching }
} NOP, but must be associated with a matching {

Implicit loop

There are several flavors of CBF which depend on how the implicit loop is defined. The following table outlines the entry and exit conditions of the current cell for the implicit loop according to the flavor. If the entry condition is not met on the current cell, then the program never executes. If the exit condition is not met on the current cell, then the program loops.

Flavor Entry Exit
Regular CBF Non-zero Zero
Reversible CBF Non-zero Non-zero
Inverted Reversible CBF Zero Zero
Inverted Regular CBF Zero Non-zero

See also