Interstack
Interstack (formerly Brainstack (nothing to do with Brainstack)) is an esoteric programming language created by User:PythonshellDebugwindow in 2019.
Overview
Interstack is a stack-based language with some influence from brainfuck. Its only value storage areas are the stack and the value cell; the stack can hold an unlimited number of values and is initially empty, while the value cell, which is used for operations such as input and output, can hold only one value, initially 0. All values in Interstack are wraparound integers from 0 to 255. Each command is one character.
Commands
| Command | Effect |
|---|---|
+ |
Pushes the value in the value cell to the stack, then sets the value cell to 0. |
^ |
Pops the value at the top of the stack into the value cell. |
@ |
Peeks the value at the top of the stack into the value cell. |
% |
Swaps the value at the top of the stack with the value in the value cell. |
_ |
The opposite of ^, sets the value at the top of the stack to the value in the value cell (doesn't push, just sets), then sets the value cell to 0.
|
~ |
Reverses the stack, such that its first item becomes its last, its second becomes its second-last, and so on. |
* |
Sets the value cell to 0. |
# |
Sets the value cell to 65. |
? |
Reads a line of user input, then sets the value cell to the sum of the input characters' Unicode codepoints (not including the trailing newline). |
! |
Outputs the Unicode character whose codepoint is the value in the value cell. |
. |
Halts the program. |
< |
Decrements the value cell. |
> |
Increments the value cell. |
& |
Adds the value in the value cell to the value at the top of the stack, then sets the value cell to 0. |
( |
Opens a for loop, which loops value in value cell times. If the value cell changes, then the loop's iteration count will stay the same; for example, #(*) loops 65 times.
|
) |
Closes a for loop. |
; |
Breaks out of the innermost for loop. |
All other characters are ignored.
If % is executed more than once, then . must be the last character in the program (including newlines) in order for termination to be successful, even if the program halts early due to another . command.
The commands ^, @, %, _, and & invoke undefined behaviour if executed when the stack is empty, and ; invokes undefined behaviour if it is executed outside of a loop.
Examples
Hello, world!
#>>>>>>>!*>>>>>>>>>>(>>>>>>>>>)>!+@>>>>>>>!!+@~>>>!(>>>>)>!<<<<<<<<<<<<!+@~(>>>)<<<<<<<<<!<<<<<<<<!>>>!^!^<!^>!*>>>>>>>>>>!
Cat program
Loops 2554 times. Input one character at a time.
<((((?!*<))))
Truth-machine
Outputs 2554 + 1 characters if 1 is input.
+>>>(>>>>)(#&)?+@~&^>(*<((((%!%)))))^!.
An alternative truth-machine, with the same limitation:
>>>(>>>)(>>>)>++>>>(>>>>)(#&)?&^>(*<((((%!%)))))^<!.
Add two inputs
Adds the Unicode codepoints of two characters, and outputs the Unicode character at the resulting codepoint. Input each character on its own line.
?+?&^!
Computational class
As Interstack can only execute bounded for loops, it is total, and therefore not Turing-complete.
External resources
- An interpreter written in Node.js
- Rust interpreter (dead link)