esolang

'NULL'

A programming language in zero dimensions. A program is one positive integer.

Turing complete: unknown · ●●● hard · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: cat

The idea

In NULL the whole program is a number, x. Each step divides x by its smallest prime factor and multiplies a second number, y, by the same prime. The prime is the instruction. Primes are counted from 2 and wrap after 14, so 2, 47 and 107 are all the same instruction.

Read the story

Loops come from instruction 41, which swaps x and y. By then y holds every prime that has run so far, so swapping starts the same instructions over. The cat is 42539, which is 7 × 59 × 103. It reads a byte, prints it and swaps. The Hello World is a number of 170 digits.

The machine

Three queues of bytes, one selected, and the two numbers x and y.

PrimeDoesPrimeDoes
2, 3Select the next, previous queue19, 23Move the front to the next, previous queue
5Print the front byte29Drop the front
7Read a byte into the front31Enqueue y mod 256
11, 13Subtract the front from y, add it37Skip the next prime if the front is 0
17Add y mod 256 to the front41Swap x and y
43End

The specification leaves the end of the input open. Reading past it ends the program, and so does x reaching 1.

Example

Expected: 0
Expected: Hello, World!

Further

Ideas it shows

Non-textual

Unknown year

Write your own in Run Convert a program from 'NULL'

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run null -e '42539' --input 'cat'
shib manual null

Source

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

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

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