esolang

Z

A whole language in two letters. Hello World is eleven lines of z.

Challenger5, 2016 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 72 101 108 108 111 32 87 111 114 108 100 33

The idea

Challenger5 made Z in 2016. A program uses only z, Z, the space and the line feed. A word is one to three letters, a statement is words parted by one space, and statements are parted by a line feed or by two spaces. The case of each letter matters.

Read the story

Under the letters is a small assembly. There is one number, A, a grid of numbers and a pointer into the grid. The specification calls it a preparing system. Most statements put a number in A first, and the next statement uses it.

The machine

StatementDoes
zRead a number into A
ZPrint A
zz z and digitsSet A to a number, one word per digit
zz ZSet A to the cell at index A
zZMove the pointer to A
ZzPut A in the cell at the pointer
ZZ z ZZ ZAdd A to that cell, or take A from it
zzzJump to line A
zzZJump to line A if the cell at the pointer is 0

The digits are z 1, Z 2, zz 3, zZ 4, Zz 5, ZZ 6, zzz 7, zzZ 8, zZz 9 and zZZ 0, so zz z zzz Z sets A to 72. Lines count from 1. The specification says its Hello World prints ASCII values, so Z prints A as a number, one per line.

Example

The truth machine reads a number into the cell at the pointer.
Expected: 0

The truth machine reads a number into the cell at the pointer. If it is 0, zzZ jumps to line 4, which prints 0. Otherwise line 3 prints 1 and jumps back to itself forever. The Fibonacci program is included too. It keeps two cells and adds each into the other, and it prints 0 twice before 1, 1, 2, 3, 5.

Further

Ideas it shows

Also in Turing tarpits

Write your own in Run Convert a program from Z

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run z -e 'z  Z' --input '42'
shib manual z

Source

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

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

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