StairCase
The spaces in front of a command say which cell it works on, so a program looks like a staircase.
2021 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
StairCase was made in 2021 as an npm package. There is no stack, only numbered cells. Each line holds one command, and the number of spaces before it picks the cell. No spaces is cell 0 and one space is cell 1. A program that moves between cells climbs up and down the page.
Read the story
It runs on JavaScript numbers, so cells hold fractions and 5 % -2 is 1. An empty line ends the program.
The machine
| Command | Does |
|---|---|
` | Put a number in the cell | |
\ | Put the rest of the line in as character codes, then a 0 |
@N | Copy cell N |
" # | Print the number, with and without a line end |
. , | Print characters from the cell on, with and without a line end |
$ ? _ | Read a number, a string with its length, a string |
+ - * / % | Arithmetic with a number, @N or -@N |
& \| ^ ~ { } | Bitwise and, or, xor, not and shifts |
: = ! < > | Jump always, if 0, if not 0, if below 0, if above 0 |
[ ] | Call, keeping the next line in the cell, and return |
' ( ) | Random number, truncate, round |
; | Comment |
A line number is 5, +2 or -3 from this line, @N for the line in cell N, or +@N and -@N.
Example
The string goes into cells 0 to 5 and .
The string goes into cells 0 to 5 and . prints up to the 0.
A sum. Cell 0 gets 5 and then 3 more, and the one space before `7 puts 7 in cell 1.
Relative jumps. Line 1 jumps to line 5, which jumps back to line 2; the empty line 4 ends it.
A countdown. !-2 jumps two lines back while cell 0 is not 0.
Patterns it teaches
- Encoding tricks: indentation as an address.
- Turing completeness: unbounded cells and conditional jumps.
Further
See also
Cell-based
Write your own in Run Convert a program from StairCase
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: staircase.
Command line
shib run staircase -e '\Hello
, ; Print Hello to the STDOUT'shib manual staircaseSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/staircase.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org