esolang

Xcf4••

Brainfuck written with three symbols, two at a time.

Turing complete: yes · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: x

The idea

Xcf4•• uses only ☺, ☻ and π. Every command is a pair of them, and eight of the nine pairs are the eight commands of brainfuck. The ninth, ☻☺, is the move loop [>+<-] as one command. The specification says the name as "ex see ef four double alt seven".

The machine

PairBrainfuckDoes
☺☺ ☻☻+ -Add or take 1 from the cell
π☻ π☺> <Move right or left
ππ ☺☻. ,Print the cell; read a byte into it
☺π ☻π[ ]Loop while the cell is not 0
☻☺[>+<-]Move the cell's value onto the next one

The Common Lisp interpreter on the specification reads the source two characters at a time. A pair that is no command moves it on by one character, so spaces and other text are comments. Cells are bytes that wrap, and the tape has no end either way. The interpreter also prints a >> prompt before each read; this implementation leaves the prompt out.

Example

The first is the cat, ,.
Expected: A
Expected: x

The first is the cat, ,. in brainfuck. The second is +++++[>+++++++++++++<-]>., five times 13. The third reads a byte, moves it one cell on with ☻☺ and prints it from there.

The truth machine is ,.[-->+[>>]<[.]<<]. On 0 it prints 0 and counts the cell down by twos to 0. On 1 the count never reaches 0, and once the counter beside it wraps it prints 1 forever.

Expected: 0

The ASCII Cycle, ☺☺☺πππ☺☺☻π, is +[.+]. It prints every byte from 1 to 255 and stops when the cell wraps to 0.

Patterns it teaches

Further

Xcf4•• builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from Xcf4••

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run xcf4 -e '☺☻ππ' --input 'x'
shib manual xcf4

Source

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

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

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