esolang

Brainlisp

Brainfuck's eight commands, dressed up as Lisp calls.

Hakerh400, 2020 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: cat

The idea

Hakerh400 made Brainlisp in 2020 as a small test for Lisparser. Each brainfuck command becomes a call in parentheses, and the two brackets become one call, (loop ...), that holds its body. A program means exactly what the same brainfuck would mean.

Read the story

The Hello World program is 66 calls and 3 loops in 456 characters, the same 72 commands as a brainfuck program. It opens with (inc) and then two (dec), so it counts on cells that wrap from 0 to 255.

The machine

CallbrainfuckDoes
(left) (right)< >Move the pointer
(inc) (dec)+ -Add or take 1
(in),Read a character into the cell
(out).Print the cell as a character
(loop ...)[ ... ]Run the body while the cell is not 0

The specification lists the calls and nothing more. Its examples settle the rest. Cells are bytes that wrap, the tape runs both ways, and reading past the end of the input gives 0, or the cat would never stop.

Example

The truth machine never compares anything.
Expected: Hello, World!

The truth machine never compares anything. It prints the input, then lays its code out as a row that falls by 1 down to 1, 48 cells for 0 and 49 for 1, starting one cell left of where it began. Then it walks back over the row two cells at a time. Whether the code is even or odd decides where the walk stops. For 0 it stops beside an empty cell. For 1 it stops beside the code itself, which (loop (out)) then prints forever.

Expected: 0

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Brainlisp

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainlisp -e '(in) (loop (out) (in))' --input 'cat'
shib manual brainlisp

Source

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

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

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