LogicGates/exGates
Every command is one number, the whole truth table of a gate written out as digits.
2025 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
exGates is a family of dialects of LogicGates, a brainfuck relative whose commands are the sixteen logic gates of two bits. In exGates-n the accumulator and the cells hold digits from 0 to n-1, and a command is a number. Write that number in base n with n×n digits and it is the gate's table, one result for every pair of accumulator and cell. A positive number puts the result in the accumulator, a negative one in the cell.
Read the story
The tables grow fast. exGates-2 has 16 gates and exGates-10 has 10^100. The specification prints HI! in exGates-74 with three numbers, and the first of them is 10,236 digits long.
The machine
An accumulator and an endless tape of cells, all 0 at the start.
| Code | Does |
|---|---|
12 | Run gate 12, the result to the accumulator |
-12 | Run gate 12, the result to the current cell |
0 | Nothing |
< > | Move along the tape |
[ ] | Loop while the accumulator is not 0 |
, . | Read into the accumulator; print it |
( ) | A comment |
The specification does not say how a program picks its n, so the first line names it, such as exGates-74. Up to base 10 a value is read and printed as a digit, above that as a character.
Example
The XKCD random number is 4 times 5^24.
The XKCD random number is 4 times 5^24. In base 5 that is a 4 and 24 zeros, so with the accumulator and the cell both 0 the gate gives 4. In exGates-2, 12 is 1100 in binary, the table of NOT on the accumulator.
The one-digit A+B has its first gate positive, which leaves the accumulator as it was, so it prints only the second digit. With a minus in front the first gate copies the first digit into the cell, and the second gate adds the two modulo 10.
Patterns it teaches
- Encoding tricks: a whole function packed into one number.
- Turing completeness: every dialect can do what LogicGates does, and LogicGates has all of boolfuck.
See also
LogicGates/exGates builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from LogicGates/exGates
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: logicgates-exgates.
Command line
shib run logicgates-exgates -e 'exGates-5
238418579101562500.'shib manual logicgates-exgatesSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/logicgates-exgates.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org