esolang

QX

Two commands. One adds to a cell. The other compares, moves the pointer and maybe jumps, all in one go.

↑, 2025 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 2 steps Pointer at 1 Memory: [1]: 7

The idea

↑ made QX in 2025. Memory is a row of numbers with one pointer, as in brainfuck, but no command just moves the pointer. X compares a number with the cell before the pointer, then steps back and jumps or steps forward. So a step forward is X ∞ 0, a test no finite cell passes, and a step back is X -∞ n with n the next line, a test every finite cell passes.

Read the story

The specification translates brainfuck into QX twice, once with ∞ for unbounded cells and once without it for bytes. Aadenboy wrote the Lua interpreter in the specification, and this implementation follows it.

The machine

CommandDoes
Q aAdd a to the cell at the pointer
X a bIf a is at most the cell before the pointer, step back and jump to line b; else step forward

Lines count from 1. A number can be ∞ or -∞, and ? reads a line of input as a number. The run ends when the next line is not there, below 1 or past the last. QX has no output of its own, so the interpreter prints how many steps the run took, where the pointer is and the memory.

Example

That is the A+B Problem, both numbers added into cell 1.

That is the A+B Problem, both numbers added into cell 1. The second version keeps A in cell 1 and B in cell 2 and moves A over one at a time. Each round X 1 6 steps back to cell 1 while it holds 1 or more, Q -1 takes one off, and Q 1 adds it to cell 2. When cell 1 is empty, X 0 12 jumps past the end.

Expected: 23 steps Pointer at 2 Memory: [1]: 0 [2]: 7 [3]: 0

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from QX

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: qx.

Command line

shib run qx -e 'Q ?
Q ?' --input '3
4'
shib manual qx

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/qx.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org