esolang

XOṘ Mạchịne

Two bits, one operation, and the answer is always whether a is larger than b.

A, 2019 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 13 known programs · Test method

Run it

Expected: 1

The idea

A made XOṘ Mạchịne in 2019, a one-instruction machine whose only instruction is XOR. It reads two bits, a and b, runs the program, and prints 1 if a is larger than b and 0 if not. The constant 1 is the only other thing a program can name. The specification shows that some gates can be built this way and that OR cannot.

The machine

The program is read two characters at a time. Each pair names a target and a source.

PairDoes
aa ab a1a becomes a XOR a, a XOR b or a XOR 1
ba bb b1b becomes b XOR a, b XOR b or b XOR 1

Any other pair does nothing. The input is the two bits written together, such as 10. Since the result is a > b, the empty program already computes a AND NOT b.

Example

abbb stores a XOR b in a and clears b, so the test a > 0 gives a XOR b.

abbb stores a XOR b in a and clears b, so the test a > 0 gives a XOR b. b1 flips b, and a > NOT b is a AND b.

Expected: 0
Expected: 1
Expected: 1

Three programs in the specification compute something other than their heading under its own C implementation. abbabb leaves a XOR b in a and clears b, so it gives a XOR b, not (NOT a) AND b. aa1 and b1aa1 have an odd length, so their last 1 pairs with nothing and they always print 0.

Expected: 1
Expected: 0

Patterns it teaches

Further

OISC

Write your own in Run Convert a program from XOṘ Mạchịne

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: xor-machine.

Command line

shib run xor-machine -e 'b1' --input '11'
shib manual xor-machine

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/xor-machine.js

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

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