Nhohnhehr
One small square room that never changes. Walk out of it and a turned copy of the room appears on the other side.
Chris Pressey, 2010 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 5 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Chris Pressey designed Nhohnhehr between 4 and 8 December 2010. A program is a single square room drawn inside an ASCII box. An instruction pointer walks through it, bouncing off mirrors and printing bits, like in Befunge. Text outside the box is ignored.
Read the story
The room itself can never be changed. What can change is how many rooms there are. Depending on the edge mode, leaving a room either wraps around to its other side or steps into the next room. If that room does not exist yet, a copy of the current one is made, possibly turned, and placed there. A row of rooms turned this way or that is the only memory the language has, which is enough to build a stack.
The machine
The pointer starts on $, heading east. Input and output are bits, eight to a byte, most significant first.
| Cell | Does |
|---|---|
/ \ | Mirrors |
# | Skip the next cell |
0 1 | Output a bit |
? | Input a bit: turn left on 0, right on 1, go straight at the end |
@ | Halt |
= | Edge mode wrap: leave one side, come back on the other (the start mode) |
& | Edge mode copy: a new room is an exact copy |
} { ! | Edge mode copy turned clockwise, anticlockwise, or half a turn |
The characters in a turned copy keep their shape, so a / stays a / even though the room around it turned. Output bits left over at the end, fewer than eight, are dropped.
Example
Each row carries four bits.
Each row carries four bits. At the end of a row the pointer wraps around to the \ at its start, which sends it down to the next row's \, which sends it east again. The 16 bits spell H and i.
Further
Ideas it shows
See also
Two-dimensional languages
Write your own in Run Convert a program from Nhohnhehr
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: nhohnhehr.
Command line
shib run nhohnhehr -e '+------+
| /}|
|&#/$?@|
| / \&|
| |
| { |
|\\ |
+------+' --input 'Hi'shib manual nhohnhehrSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/nhohnhehr.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org