Whereismystack
Jump to navigation
Jump to search
Overview
Whereismystack is a stack-based esoteric programming language that challenges the programmer to manipulate a string-array memory. Unlike traditional stack languages, its output is determined by a unique "Last-Two-Digits" consolidation rule, where only the final part of a concatenated memory string is preserved.
Architecture
- Memory (Stack): A dynamic array of strings, initialized as
["1", "1"] - Output Buffer: A separate integer array that stores values processed by the
=operator. - Execution: The interpreter processes each line independently, resetting the memory to its initial state for every new line.
Commands
| Command | Name | Description |
|---|---|---|
+ |
Add | Add the last two elements from memory and pushes the result back to memory. |
- |
Sub | Subtracts the last element (Top) from the second-to-last element. If the result is negative, the absolute value is pushed to memory. |
* |
Mul | Multiplies the last two elements in memory and pushes the result. |
/ |
Div | Divides the second-to-last element by the last element. Note: Division by zero terminates the program immediately. |
= |
Consolidate |
|
?MN |
Range Combine & Push | Accesses a predefined sequence from index M to N-1. These values are summed into the current memory state. The final combined value modulo 128 is pushed to memory. (Constraint: N - M ≥ 2).
|
r |
Reverse | Swaps the positions of the last element and the second-to-last element in memory. |
^ |
Print / Flush | This operator is context-sensitive based on the preceding character:
|
Computational Model
The language utilizes two distinct storage structures:
- Memory: A stack or list used for active calculations and string manipulations.
- Output Buffer: A secondary storage area specifically for ascii code.
Implementation Notes
- The initial state of memory is
["1", "1"]. - All ASCII conversions should strictly follow the 7-bit standard (0-127) via modulo 128.
Implementation Details
- Initial State: Every line starts with
memory = {"1", "1"}. - Numeric Conversion: Strings are converted to integers for calculation and back to strings for storage.
- The last Two values This is the core mechanic.
example
1) H
input : ++--?15r=^
output : H
2) Fibonacci sequence
input : +++++++++++^
output : 1123581321345589144
link
here is my interpreter :
https://github.com/realgitman1/whereismystack_interpreter.git