NULL

From Esolang
Jump to navigation Jump to search

NULL is a programming language in zero dimensions. Programs in it are single positive integers of arbitrarily large size.

Runtime environment

The environment available to a NULL program consists of three queues of bytes, initially empty, and two arbitrarily large integer variables, x and y. x is set to the program, while y is set to 1.

Then x is divided by its smallest prime factor, y is multiplied by the same, and the instruction corresponding to the prime factor is executed.

Instructions

2 Select the next queue (wrapping around).
3 Select the previous queue (wrapping around).
5 Output the byte at the front of the selected queue (NUL if the queue is empty). NUL is '\0' (ASCII character 0).
7 Input one byte and replace the value at the front of the selected queue with it; or, if the selected queue is empty, enqueue the value there. It is currently undefined what to do when EOF has been reached.
11 Subtract the byte at the front of the selected queue (0 if the queue is empty) from y. If this makes y less than zero, y is set to 0.
13 Add the byte at the front of the selected queue (0 if the queue is empty) to y.
17 Add y mod 256 to the byte at the front of the selected queue, or enqueue y mod 256 there if the queue is empty.
19 Remove the byte at the front of the selected queue (use 0 if the queue is empty) and enqueue it to the rear of the next queue (wrapping around).
23 Remove the byte at the front of the selected queue (use 0 if the queue is empty) and enqueue it to the rear of the previous queue (wrapping around).
29 Remove the byte at the front of the selected queue.
31 Enqueue y mod 256 at the end of the selected queue.
37 If the selected queue is empty or the byte at the front of it has a value of 0, divide x by its smallest prime factor and multiply y by that number.
41 Switch the values of x and y.
43 End the program.

The instructions loop for every 14th prime number, meaning, for instance, 47 is equivalent to 2.

Examples

Hello, world!

This 170-digit number prints the words Hello, World!.

18090462148251759497492444420325028573004825667450262208483921113691874262881209
11270348382658758112435115975300629489467941484939334913482219468626524471028850
8550347259

Cat program

This 5-digit number is a cat program. Note that its behavior on end of file is undefined.

42539

Truth-machine

461190218321951113117134453091156860683

External resources

See also

  • EINE, one-dimensional NULL.