Unefunge-98 and Trefunge-98
Funge-98 on a line and in a cube. The same instructions as Befunge-98, with one direction pair fewer or one more.
Chris Pressey, 1998 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 9 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Funge-98 is a family. Befunge-98 is its two-dimensional member, and the specification describes the others in the same breath. Unefunge runs on a single line, so it has only left and right, and Trefunge runs in a cube, with a third direction pair for going up and down between layers.
Read the story
Every instruction that takes a position takes a vector with one number per dimension. g and p pop one coordinate in Unefunge and three in Trefunge, and the storage offset of a new stack is a vector of the same size. TIO runs both with PyFunge.
The machine
The full Befunge-98 machine with the number of dimensions changed.
| Unefunge-98 | Trefunge-98 | |
|---|---|---|
| Space | one line; line breaks in the source are skipped | rows from lines, a form feed starts the next layer |
| Turning | > < _ r x only; ^ v \| [ ] w reflect | also ^ v \| [ ] w in the x-y plane, h and l between layers, m as an if between them |
| Vectors | 1 number | 3 numbers |
In both, the space has no edge and wraps round, t starts a second pointer and y reports the machine. Fingerprints, files and system calls are left out and reflect. Which way h goes is a guess. This implementation sends it to the layer before, and l to the layer after.
Example
The Hello World pushes the text backwards with a count of 12 on top, and ck, prints thirteen letters.
The Hello World pushes the text backwards with a count of 12 on top, and ck, prints thirteen letters. c is 12, and k runs the comma twelve more times. The second program starts by going west, wraps round to the far end of its line, skips the comment between the semicolons and prints two fetched letters. The cat stops when ~ meets the end of the input and reflects onto @.
Further
- esolangs.org/wiki/Funge-98
- PyFunge, the interpreter TIO runs
See also
Multi-dimensional languages
Self-modifying
Write your own in Run Convert a program from Unefunge-98 and Trefunge-98
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: trefunge-98-pyfunge.
Command line
shib run trefunge-98-pyfunge -e '#@~,' --input 'echo'shib manual trefunge-98-pyfungeSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/trefunge-98-pyfunge.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org