BoolX
Numbers of any length, written one bit at a time.
Andrea Calligaris, 2008 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Andrea Calligaris made BoolX in 2008, after brainfuck. A cell holds a binary number of any length, stored lowest bit first. You do not add to a cell; you select one of its bits and set it to 0 or 1. A bit can also be null, which marks the end of the number, so a cell knows how long it is.
Read the story
Around that sit tools brainfuck lacks. There are if and else on the selected bit, labels with a goto, and functions. A call gets a fresh row of cells, so the only way to pass values in and out is a global queue. Like brainfuck, BoolX can only print a cell as a character. To print a number in binary, a program has to walk its bits and print a 0 or 1 for each.
The machine
A row of cells, each with its own selected bit.
| Char | Does |
|---|---|
> < \| | Next, previous, first cell |
+ - = | Next, previous, first bit |
_ ^ * % | Set the bit to 0, to 1, cut the number off here, clear the cell |
] [ | Print the cell as a character, read one |
# & | Enqueue the cell, dequeue into it |
? " ! ; | If the bit is 1, if it is null, else, end if |
: / \ $ | Label, next label, previous label, first label |
' @ ~ | Go to the label, call it, return |
Example
The Hello World program sets the seven bits of each character, lowest first, and prints.
The Hello World program sets the seven bits of each character, lowest first, and prints. _+_+_+^+_+_+^ is 0001001 read backwards, which is 72.
The compacted example adds 64 and 29 bit by bit with a function and a carry, and prints both numbers and the sum in binary with another function.
Ideas it shows
See also
Queue-based
Cell-based
Write your own in Run Convert a program from BoolX
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: boolx.
Command line
shib run boolx -e '%_+^+_+_+_+_+^+*]%^+^+^+^+_+^+^+*]%^+^+^+^+_+^+^+*]%_+_+^+^+_+^+^+*]%_+_+_+^+^+_+^+*]'shib manual boolxSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/boolx.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org