Simplex
A pointer on a grid of numbers, and one character per thing to do with it.
Conor O'Brien, 2015 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Conor O'Brien started Simplex in 2015. The program itself is a single line of tokens, read left to right, but the data is two dimensional. The interpreter calls the grid a slate, and there can be several slates side by side.
Read the story
Most operators take their operands from cells around the pointer. Which cells is set by two motions. At the start the first operand is the cell under the pointer and the second the cell to its left, so 6>7* leaves 42 under the pointer. Lowercase c r l u d change the first motion and uppercase C R L U D the second.
The machine
| Token | Does |
|---|---|
123 | Write the number into the cell under the pointer |
"text" | Lay the text out backwards along the direction, one character code per cell |
+ - * / : | Combine the two operands, or copy the second, into the pointer's cell |
q p _ | One less, one more, minus |
o h H | Print a number, a character, or every character back to the first 0 and a newline |
> < ^ v # | Move; # moves along the direction, ~ and ` turn it |
[ ] | Loop while the cell is not 0 |
{ } | Skip when the cell is 0 |
( )n | Repeat n times |
f | Set the fuel; each move uses one, and an empty tank stops moves and loops |
A string runs to the last quote in the whole program, so a program has room for one. Numbers are big decimals with 100 digits in the reference; this implementation keeps whole numbers below 10^21 and stops on anything else. There is no input.
Example
The countdown keeps its counter at the start of the row and uses the next cell for the newline, 10.
The countdown keeps its counter at the start of the row and uses the next cell for the newline, 10.
Patterns it teaches
- Two dimensional control flow: the code is a line, but the memory is a plane the pointer walks over.
- Code golf: the motions let one character pick its operands without naming them.
Try this
- Print the numbers 1 to 10.
- Add two numbers with
+after setting the second motion to the right withR. - Hard: print a string twice. There is only room for one string literal.
Further
See also
Also in Golfing
Write your own in Run Convert a program from Simplex
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: simplex.
Command line
shib run simplex -e '6>7*o'shib manual simplexSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/simplex.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org