Aceto
The pointer does not move in lines. It follows a Hilbert curve through a square of code.
L3viathan, 2017 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
L3viathan made Aceto in 2017. A program is a square whose side is a power of 2, and the lines are read from the bottom up, so the pointer starts in the bottom left corner. From there it follows a Hilbert curve, the fractal path that visits every cell of the square once without crossing itself. When it walks off the end of the curve, the program is over.
Read the story
So the order of the commands is the order of the curve. On a 2 by 2 square it goes up, right, then down. On a 4 by 4 square the same shape repeats four times, each copy turned to join the next.
The machine
The interpreter is Python, and the values on the stacks are Python's integers, floats, strings and booleans. There is a whole tape of stacks, and popping an empty one gives 0.
| Char | Does |
|---|---|
0-9 "..." 'c | Push a digit, a string, a character |
+ - * / : % F | Arithmetic, where / floors, : divides exactly and F is power |
= m w | Equal, greater, less or equal |
I D ! ~ y ± | Increment, decrement, not, negate or reverse, sign, absolute value |
i f b ∑ c o | Cast to int, float, bool, string; character and code point |
J £ € | Join two values, join the stack, explode a string |
p n r , | Print, newline, read a line, read a character |
s d h x U q Q l | Swap, dup, keep the top, drop, reverse, rotate, length |
( ) { } [ ] | Move along the tape of stacks, or move a value to a neighbour |
< > v ^ | Step one cell off the curve in that direction |
W E S N | The same, and the arrow turns clockwise in the code |
u \| _ # | Reverse along the curve, mirror the position if the top is true |
\ j § O ; | Skip a cell, jump along the curve, go to the start or the end |
@ & $ | Set the catch cell, raise an error, raise one if true |
X | Exit |
Any error, even running out of input, sends the pointer back to the catch cell. That is how loops end.
Example
The Hello World from Try It Online is a 4 by 4 square.
The Hello World from Try It Online is a 4 by 4 square. Along the curve its 16 cells read "Hello, World!"p, a string literal and a print.
On a 2 by 2 square the curve goes from the bottom left up, right and down, so this reads 3 4 + p.
Patterns it teaches
- Two-dimensional control flow: the path is a fractal, fixed before the program starts.
- Stack machines: a tape of stacks with Python's values.
Further
- esolangs.org/wiki/Aceto
- The interpreter, in Python
See also
Two-dimensional languages
Cell-based
Write your own in Run Convert a program from Aceto
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: aceto.
Command line
shib run aceto -e 'rp' --input 'cat
'shib manual acetoSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/aceto.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org