A two-dimensional language where a string is written as a string and 256 as 256.
TheJazzCat · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
TheJazzCat made Mail as a grid of characters with an instruction pointer moving over it, as in other two-dimensional languages. The difference is in the literals. Where most of them make a number by multiplying single digits, Mail reads 256 as 256, and "Hello World!" puts the whole string into memory at once.
Read the story
Memory is an array of integers with a pointer of its own. A string goes in as its character codes, followed by its length.
The machine
| Char | Does |
|---|---|
"text" | Write the codes of the text, then its length, and point at the length |
256 | Write 256 into the current cell |
{ } | Move the memory pointer left or right |
@ | Print the string before the pointer, as long as the current cell says |
$ , | Read a number into the current cell, print it as a number |
? | Skip the next cell if the current cell is not 0 |
> < | Send the instruction pointer right or left |
; | End the program |
The specification names only these commands, and none of them moves the instruction pointer up or down. In this implementation it stays on the first row and wraps around at its ends. Every other character does nothing. The specification does not say where the memory pointer ends after a string. In this implementation it rests on the length, and @ prints that many cells before it.
Example
The truth machine reads a number and prints it.
The truth machine reads a number and prints it. On 0 the ? does not skip, and ; ends the program. On 1 it skips the ;, and the pointer bounces between > and <, printing 1 forever.
Each number goes into a cell of its own, and the 2 at the end tells @ to print the two cells before it.
Patterns it teaches
- Two-dimensional control flow: the truth machine loops by sending the pointer back and forth.
Further
See also
Two-dimensional languages
Stack-based
Write your own in Run Convert a program from Mail
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: mail.
Command line
shib run mail -e '$,?;>,<' --input '0'shib manual mailSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/mail.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org