NullScript 2
256 cells, 19 commands and a queue of eight. Every sum takes its two values from the queue.
a stone arachnid, 2019 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
The esolangs.org user a stone arachnid made NullScript 2 in 2019, after Deadfish~ and brainfuck. It is a superset of NullScript 1. NullScript 2 can add and take 1, square a cell, set it to 0, and read and print numbers.
Read the story
A sum takes its two values from the front of a queue that holds at most eight. * puts a copy of the current cell at the back, and the result goes into the current cell. When the queue is empty the values come from the input instead.
The machine
| Command | Does |
|---|---|
[ ] | Take 1 from the current cell, or add 1 |
; ~ | Square it; set it to 0 |
. , | Print it as a number, or as a character |
& | Read a whole number into it |
< > | Move the pointer; it wraps around at 0 and 255 |
* | Put a copy of the cell at the back of the queue |
' | Take the front of the queue into the cell |
+ - x / " | Take two values from the queue and put their sum, difference, product, quotient or remainder in the cell |
{ | On 0, go on after the next } |
} | Go back to the last {, which tests the cell again |
q | End the run |
Brackets do not nest. Numbers print with nothing between them.
Example
The Hello World counts each character up from 0 with ], prints it with , and clears the cell with ~.
The Hello World counts each character up from 0 with ], prints it with , and clears the cell with ~. That is 1,154 commands, 1,129 of them ]. Squaring is shorter. 8 squared is 64, and 8 more is 72, an H.
Six and seven go into the queue, and x multiplies them into the third cell.
With the queue empty, + reads both of its values.
The cat for numbers prints each one until a 0, and the 0 as well.
Further
See also
Cell-based
Write your own in Run Convert a program from NullScript 2
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: nullscript-2.
Command line
shib run nullscript-2 -e '&.{.}' --input '0'shib manual nullscript-2Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/nullscript-2.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org