Interstack

From Esolang
Jump to navigation Jump to search

Interstack (formerly Brainstack (nothing to do with Brainstack)) is an esolang made by User:PythonshellDebugwindow.

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 infinite values, while the value cell, which is used for operations such as input and output, can hold only one value. All Interstack values are wraparound integers from 0 to 255. Each character is one command.

Commands

Command Effect
+ Pushes the value in the value cell to the stack, then set the value cell to 0
^ Pops the value at the top of the stack into the value cell (undefined behaviour if the stack is empty)
@ Peeks the value at the top of the stack into the value cell (undefined behaviour if the stack is empty)
% Switches the value at the top of the stack with the value in the value cell; if this is used more than once a . is needed at the end of the code
_ The opposite of ^, sets the value at the top of the stack to the value cell (doesn't push, just sets), then sets the value cell to 0
~ Flips the stack (the first value becomes the last, the second becomes the second-last, etc.)
* Sets the value cell to 0
# Sets the value cell to 65
? Get a line of user input, then set the value cell to the sum of all the input characters' ASCII values, minus the trailing newline
! Outputs the ASCII value of the value cell, which keeps its value
. Ends the code early; only necessary to terminate if more than one '%' is used
< Decrements the value cell by 1
> Increments the value cell by 1
& Adds the value cell to the value at the top of the stack, then sets the value cell to 0
( Opens for loop, loops value in value cell times (if the value cell changes, the loop's number of iterations doesn't, e.g. #(*) loops 65 times)
) Closes for loop
; Ends for loop early

All other characters are ignored.

Examples

Hello World

#>>>>>>>!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!>>>>>>>!!>>>!*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!#>>>>>>>>>>>>>>>>>>>>>>!>>>>>>>>>>>>>>>>>>>>>>>>!>>>!<<<<<<!<<<<<<<<!

Cat program

Loops 2554 times. Input one character at a time.

<((((?!*<))))

Add two inputs

Input two characters, one at a time.

?+?(^>+)^!

Computational class

As Interstack can only execute bounded for loops, it is total, and therefore not Turing-complete.

External resources