LogicGates
Sixteen letters, one for every gate with two inputs, and a single bit to hold the answer.
None1, 2025 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
None1 made LogicGates in 2025. There are exactly 16 functions from two bits to one bit, and LogicGates gives each a letter. The first input is always a one-bit accumulator and the second is the cell under a pointer on a tape of bits. A capital letter writes the answer to the accumulator, the same letter in lower case writes it to the cell. Add brainfuck's moves and loops and the specification shows that every command of Boolfuck can be built, so it is Turing complete.
The machine
| Gate | 00 01 10 11 | Is |
|---|---|---|
A | 0 0 0 0 | False |
B | 0 0 0 1 | AND |
D F | 0 0 1 1, 0 1 0 1 | the accumulator, the cell |
G | 0 1 1 0 | XOR |
H | 0 1 1 1 | OR |
N L | 1 1 0 0, 1 0 1 0 | NOT accumulator, NOT cell |
Q J | 1 1 1 0, 1 0 0 0 | NAND, NOR |
R | 1 1 1 1 | True |
The other five letters, C E K M P, fill in the rest of the table; I and O are not used.
| Command | Does |
|---|---|
< > | Move the pointer |
[ ... ] | Loop while the accumulator is 1 |
. | Print the accumulator as 0 or 1 |
, | Read a character and keep its lowest bit |
( ... ) | A comment |
Example
The XKCD random number, 4, in unary and in binary.
The XKCD random number, 4, in unary and in binary.
Adding two bits. d copies the first bit into the cell, and G leaves the XOR of the second bit and the cell in the accumulator.
The looping counter, R[[>F]rR[.<F]A.R], never stops. It prints 10110111011110 and on, each 1 longer than the last.
Patterns it teaches
- Turing tarpit: a bit, a tape and a table of gates.
Further
See also
LogicGates builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from LogicGates
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: logicgates.
Command line
shib run logicgates -e ',N.' --input '0'shib manual logicgatesSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/logicgates.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org