Stairlang
Stairlang, or in full, Somebody Somewhere Was Drunk At Some Point In The Design, Implementation And Construction Of This Staircase, is a 2d stack-based cursor-based esolang made by Ϫ (talk) and inspired by dolfins grace.
Commands and Syntax
A Stairlang program is made of a pile of commands. No command (with exceptions) can be above nothingness, only the bottom of the file or another command. Violating this rule will throw an error and render the command a noop. The cursor starts at the top left headed right and whenever it finds itself above an empty tile, it falls as far as it can. All commands can be moved into from the sides, however. At the final tile, it will wrap around to the other edge with the same Y-value.
Clarified falling mechanics No! Yes XXXXX VVVVV > > > > >>>> > #--# > #--# # # >># #
Commands
I Push the user input onto the stack. After one use, all further 'I's are noops. ! Create a new, 'WIP' value and push it to the stack. 0-9 Add this digit to the end of the WIP value at the top of the stack. If the top of the stack is not a WIP value, act as a noop. X Finalize the WIP value at the top of the stack, converting all its digits into a static integer value. If the top of the stack is not a WIP value, act as a noop. ^ Push the cursor on top of this command. Useful for loops. - If there is a command on both sides of this command, do not throw an error during construction. (This means it can float if connected from both left and right.) If either pillar vanishes, this command will delete itself. # No effects, just for stability. | Flip the cursor. . Output the top stack value as an integer. ' Output the top stack value as an ASCII code. { If the top value is 1, destroy the command to the left and shift all commands above it down. (Has right variant '}'.) ] If the top value is 1, swap the command to the left with the command to its left. If any commands find themselves above an empty space, shift them down. (Has right variant '['.) * Read the top item of the stack and push a duplicate onto the stack. @ End the program. $ Double the top item of the stack. V Delete the top item of the stack. ? If the top value is 1, push the cursor on top of this command. + Add the top two values of the stack and push the sum on top. - Like +, but subtraction instead > Force the player to go right. (Has left variant '<'.) ; Drop the top value to the bottom of the stack. : Pull the bottom value to the top of the stack.
Computational class
Stairlang is Turing complete since it is able to implement tag systems.
The stack is used as a queue for the word's symbols, with each element being a member of the alphabet, its number corresponding to an enumeration of the alphabet starting at one. The general program structure is like so:
> rule > ^----------------^ ^ > rule ^ ^ ^-----------^ ^ ^ > rule ^ ^ ^ ^------^ :?!1X-?!1X-? rule ^>
First it pulls up the bottom of the stack (the start of the word). It then checks immediately if it is 1. If so, it pushes the pointer all the way up to a platform holding up the code for the rule corresponding to symbol 1. If the BOS was not 1, decrement, and repeat. This can be used to check for any given value being at the bottom of the stack. Note that the rule platforms are all right-connected to a final pillar of upwards pushes. This ensures that the cursor ends up falling onto the >
at the end. The pillar could also be made of #
.
At the start of each rule is some cleanup code which enforces the symbol deletion policy of the tag system. For example, a 2-tag system would have all rules begin with V:V
which pops the bottom of stack (which was pulled up to the top), then pulls up the next and pops it as well. After that, a sequence of number pushes can be done. The 2-tag system rule to add A B C assuming A = 1 would be V:V!1X!2X!3X
.
Examples
One-time Cat
I'@
Infinite Double Machine
!1X ###$ .
Truth Machine
I* .?@
"Trap"
><
"Search"
>?V-# ^## < .@
Hello World (Linear)
!72X,!101X,!108X,!108X,!111X,!32X,!119X,!111X,!114X,!108X,!100X,!33X,@
Hello World (Pillar)
@ 33# 100 108 114 111 119 32# 111 108 108 101 72#] !^###X <