CQfuck
Brainfuck whose loops wait in a queue. Every loop runs once before it asks whether to go on.
ChuckEsoteric08, 2023 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
ChuckEsoteric08 made CQfuck in 2023. It is brainfuck with one change. The brackets work through a call queue. [ only writes its own position at the back of the queue, and ] takes the position at the front. If the cell is not 0, the program goes back to that [.
Read the story
So [ never skips anything, and a loop body always runs at least once. Brackets also need not pair up. The queue is first in, first out, so two loops that are open at once take turns. The looping counter ends in [.[>.<], two [ and one ]. Every pass through the first [ queues one more copy of the second, so it prints a line of one star, then two, then three, and never stops.
The machine
| Char | Does |
|---|---|
+ - | Add or take 1 from the cell, modulo 256 |
> < | Move right or left on the tape |
. , | Print the cell; read a byte |
[ | Put this position at the back of the queue |
] | Take the front position and go back to it if the cell is not 0 |
When ] goes back, the [ there runs again and queues itself once more. The specification leaves two things open. , reads 0 at the end of the input, and a ] with an empty queue does nothing.
Example
The first is the Print HI.
The first is the Print HI. Seven passes add 10 each to the second cell, which makes 70. Two more is H and one more is I. The second is the truth machine. It copies the input into two cells, takes 48 from one and prints the other until that one is 0. On 0 the body still runs once and prints one 0. On 1 it prints 1 forever.
The cat, [,.], copies its input and then prints the 0 that , reads at the end.
Patterns it teaches
- Turing tarpit: brainfuck's eight commands, with loops that cannot skip their body.
Further
See also
CQfuck builds on Brainfuck.
Queue-based
Brainfuck derivatives
Write your own in Run Convert a program from CQfuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: cqfuck.
Command line
shib run cqfuck -e '+++++++[->++++++++++<]>++.+.'shib manual cqfuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/cqfuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org