esolang

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

Expected: A

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

CommandDoes
1 0Put a bit at the back
?XTake a bit; skip X when it is 0
:name XDefine a function with body X
>nameCall it
'XMake 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.

Expected: Hi

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.

Expected: cat

The same with a named function that calls itself.

Expected: bits

A test uses up its bit. The first ? takes the 1 and prints A, the second takes the 0 and skips B.

Expected: A

Patterns it teaches

Further

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 bitqueue

Source

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