OW-1
Two cells, one buffer and a grid of arrows. Every sum lands in the buffer first.
Potato Imaginator, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Potato Imaginator made OW-1 on 12 June 2022, after Befunge and assembly language. OW stands for Old Woman. There is no stack. The machine has two cells, A and B, a pointer that sits on one of them, and a buffer C. Arithmetic always reads A and B and writes C, so a program keeps moving numbers between the three with swaps and copies.
Read the story
The only test is T. It turns the path clockwise when C is not 0, so every loop is a ring of arrows that T steps out of once C reaches 0.
The machine
| Char | Does |
|---|---|
^ v < > | Point the path up, down, left or right |
? | Point it a random way |
. | Move the pointer between A and B |
+ - * / e % | Store A+B, A-B, A*B, A/B, A to the power B or A modulo B in C |
S s | Swap the pointed cell with C; swap A and B |
c p | Copy the pointed cell into C; paste C into it |
i d 0-9 | Add 1, take 1, set a digit |
# | Print C |
T | Turn clockwise unless C is 0 |
x | End |
The program starts in the top-left corner moving right. # prints C on its own line, and the grid wraps at its edges.
Example
The factorial of 6.
The factorial of 6. B keeps the product and A counts down. T sees the counter in C and sends the path down into the loop until it is 0.
The factors of 48. B runs from 2 upwards, % tests it, and - ends the loop when B reaches A.
The absolute difference of 5 and 8. A and B are counted down in turn until one of them is 0.
The specification also prints sums, square roots, Fibonacci numbers and primes, which run forever. Its Minsky machine translation reads T the other way round and does not run under the rules of the table.
Patterns it teaches
- Two-dimensional control flow: a loop is a ring of arrows.
- Counter machines: two counters and a buffer.
Further
See also
Two-dimensional languages
Cell-based
Write your own in Run Convert a program from OW-1
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ow-1.
Command line
shib run ow-1 -e '6.1>*p.dSTS#x
S
.
^ <'shib manual ow-1Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ow-1.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org