Snowman
Eight variables in the shape of a snowman, and an operator only sees the ones that are switched on.
Doorknob, 2015 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 8 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Snowman was made by the Stack Exchange user Doorknob in 2015. There is no stack and there are no names. There are eight variables, laid out like this.
Read the story
a b c
d e
f g h
Any of them can be active. An operator such as nA (add) takes its arguments from the first active variables, in the order a to h, and puts its result in the first active variable that is empty. A literal does the same. So the whole art of Snowman is choosing which variables are switched on, and moving values around between them.
The Hello World starts with (, which switches on a and f. The string goes into a, and sP prints it.
The machine
| Symbol | Does |
|---|---|
( ) { } ~ | Switch a f, c h, b d g, b e g, or all of them |
@ % ? $ & | Turn the active set round the ring, reflect it, clear it, save it, restore it |
/ \ _ [ ] \| - ' ` , . | Swap two variables | |
^ > < | Turn three variables |
* # | Move a value into or out of the permavar picked with + ! =+ =! |
12, "text", :code; | A number, an array of byte codes, a block |
Letter operators come in families: n for numbers (na add, nr range, nd divide), a for arrays (ac concatenate, am map, al length), b for blocks (br repeat, bw while, bi if), sp to print, ts to turn anything into text and vg to read a line. Written nA, with a capital second letter, the operator uses up its arguments; written na it leaves them where they were. Spaces are skipped everywhere, so 3 4 is the number 34, and vn, which does nothing, keeps two numbers apart.
Example
The second stores 3 in a and 4 in f, adds them into a, turns the 7 into text and prints it.
The second stores 3 in a and 4 in f, adds them into a, turns the 7 into text and prints it. The fourth maps a block that adds 1 over the codes of ab. In the last, the block's own string only lands the first time; after that a is full and sp keeps printing the same ho.
Patterns it teaches
- Hostile design: the operators are fine, but every argument has to be steered into the right variable by switching others on and off.
- Code golf: the small letter decides whether an operator keeps or uses up its arguments.
Try this
- Print the sum of 5 and 6.
- Read a line and print it twice.
- Hard: print the numbers 1 to 10, one per line.
Further
- esolangs.org/wiki/Snowman
- The reference interpreter, in C++, with its documentation in doc/snowman.md
See also
Also in Hostile
Write your own in Run Convert a program from Snowman
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: snowman.
Command line
shib run snowman -e '(vgsP' --input 'snow
'shib manual snowmanSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/snowman.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org