esolang

StackBit

Two stacks of bits and one loop. That is enough to be Turing complete.

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

Tested with 2 known programs · Test method

Run it

Expected: 11111

The idea

ChuckEsoteric08 made StackBit to be easy to implement. Memory is two stacks that hold only 0 and 1, and the one loop runs while the top of the current stack is 1. The specification proves it Turing complete by translating each command of BitBrain-R into a few StackBit commands.

The machine

CommandDoes
0 1Push that bit onto the current stack
~Switch to the other stack
*Pop the top
[ ... ]Repeat while the top is 1
.Print the top, for debugging

Every other character is ignored. The specification leaves the shape of the printing open, and in this implementation . prints the digit with nothing between prints.

Example

The repetition program pushes a 0 and five 1s, then prints and pops until the 0 is on top.

The repetition program pushes a 0 and five 1s, then prints and pops until the 0 is on top.

Its stack switching moves the count to the second stack as five 0s and prints them from there.

Expected: 00000

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from StackBit

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run stackbit -e '011111[.*]'
shib manual stackbit

Source

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

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

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