BitQueue
One queue of single bits. Whatever looks at a bit takes it away.
DivergentClouds, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
DivergentClouds made BitQueue in 2022. All data is a queue of bits. 1 and 0 put a bit at the back, and every command that reads the queue takes from the front, so a test uses up what it tests. A byte of output is eight bits taken in a row.
Read the story
There are no loops. Control flow is functions, named or anonymous, with three ways to return. The specification shows it is Turing complete by running Bitwise Cyclic Tag.
The machine
| Command | Does |
|---|---|
1 0 | Put a bit at the back |
?X | Take a bit; skip X when it is 0 |
:name X | Define a function with body X |
>name | Call it |
'X | Make a function of X and call it now |
" | Call the function that is running |
< | Return |
^ | Return and start the caller again |
* | Return from this function and its caller |
, . | Read a byte as 8 bits, highest first; take 8 bits and print them |
# | Print the queue as 0s and 1s |
X is one command or a block in ( ). The run halts at the end, on a return outside every function, and on taking a bit from an empty queue. The specification does not say what ^ does when the caller is the program itself; this implementation starts the program again.
Example
The specification's own example.
The specification's own example. The eight bits of 65 make an A.
A cat. The anonymous function reads a byte, prints it and starts the program again with ^. At the end of the input , puts nothing on the queue, so . finds it empty and the run halts.
The same with a named function that calls itself.
A test uses up its bit. The first ? takes the 1 and prints A, the second takes the 0 and skips B.
Patterns it teaches
- Tag systems: a queue read from the front and written at the back is a tag system's tape.
- Turing completeness: through Bitwise Cyclic Tag.
Further
- esolangs.org/wiki/BitQueue
- Bitwise Cyclic Tag, which it can run.
See also
Queue-based
Write your own in Run Convert a program from BitQueue
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: bitqueue.
Command line
shib run bitqueue -e ',.' --input 'x'shib manual bitqueueSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/bitqueue.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org