esolang

Stackint

A stack of integers is all the memory there is, and the stack itself is the only output.

PythonshellDebugwindow, 2020 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]

The idea

PythonshellDebugwindow made Stackint in 2020. Its integers have no bounds and can be negative, and every command is one character, as in brainfuck. There is no print command. When the program ends the stack is shown the way Python shows a list, [72, 101], and the specification leaves even that to the interpreter.

Read the story

Numbers are built from single digits. 72 is 98*, and 100 is 91+91+*. Taking from an empty stack gives 0, and every character that is not a command is passed over. So a quine is [1]. The brackets do nothing, the 1 is pushed, and the stack prints as [1].

The machine

CommandDoes
0 to 9Push the digit
NPush a number from the input, 0 if it is not one
+ - * /Pop A, then B, push A + B, A - B, A * B or A floored by B
&Copy the top
%Copy the bottom, onto the bottom
?Pop A; if it is not 0, pop B and jump to character B, counted from 0
!The same, taken from the bottom of the stack

A is the top, so 35- is 5 - 3. The language ignores case, so n reads a number too.

Example

The Hello World leaves the character codes of Hello World on the stack.

The Hello World leaves the character codes of Hello World on the stack.

Expected: [42]
Expected: [1]

35- takes 3 from 5. In 270-/ the 70- is 0 - 7, and -7 floored by 2 is -4. 61? jumps to character 6, past 99*, and only the 4 is pushed.

Expected: [2]
Expected: [-4]
Expected: [4]

Patterns it teaches

  • Stack machines: with a jump to a place in the program that is itself a number on the stack.

Further

Stack-based

Write your own in Run Convert a program from Stackint

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: stackint.

Command line

shib run stackint -e 'N' --input '42'
shib manual stackint

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/stackint.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org