User:JunebugEsolanging/Sandbox
Switchy! is a two-layered 2D esoteric programming language created by JunebugEsolanging. It operates on a 10x10 grid with two distinct layers, A and B. The program's execution pointer moves within these layers, following a set of unique commands.
Switchy! utilizes a stack-based architecture and a two-dimensional grid for program execution. The program's structure is defined by two separate layers, each containing a 10x10 grid of commands. The execution pointer moves within these grids, and the layers are switched using the 's' command.
Things in Switchy!
Grid: The program is executed on a 10x10 grid, with two layers, A and B. Pointer: The execution pointer starts at the top-left corner of layer A and moves according to the commands. Stack: Switchy uses a stack to store values. The stack has a maximum capacity of 16383 elements. Exceeding this limit results in elements being discarded to the "hard drive in the sky" and raises an error. Error Handling:
Out-of-bounds pointer movement causes the program counter to shatter and the program to halt. Insufficient stack elements for commands result in either a 0 being used as a default (from 2 required only getting 1) or antimatter creation (from any getting none), which destroys the stack walls then the program. Division by zero results in a "black hole" error, halting the program. * Exceeding the stack size results in a stack overflow error, that sends the values to the hard drive in the sky.
- **Input/Output:** Input and output are handled via the '*' (input) and 'p' (print) commands.
Commands
Command | Description |
---|---|
`>` | Move pointer right. |
`<` | Move pointer left. |
`v` | Move pointer down. |
`^` | Move pointer up. |
`n` (where n is a number) | Push the number 'n' onto the stack (integer). |
`i` | Input an integer and push it onto the stack. |
`c` | Input a character and push its ASCII value onto the stack. |
`+` | Pop the top two values (a, b) and push a + b. Can concatenate strings. |
`-` | Pop the top two values (a, b) and push a - b. |
`/` | Pop the top two values (a, b) and push a / b. Division by zero results in a black hole error. |
`*` | Pop the top two values (a, b) and push a * b. |
`%` | Pop the top two values (a, b) and push a % b (modulo). |
`!` | Pop the top value (a) and push a! (factorial). Discard the second value. |
`^` | Pop the top two values (a, b) and push ab. |
`=` | Pop the top two values (a, b) and push 1 if a = b, 0 otherwise. |
`≠` | Pop the top two values (a, b) and push 1 if a ≠ b, 0 otherwise. |
`>` | Pop the top two values (a, b) and push 1 if a > b, 0 otherwise. |
`≤` | Pop the top two values (a, b) and push 1 if a ≤ b, 0 otherwise. |
`<` | Pop the top two values (a, b) and push 1 if a < b, 0 otherwise. |
`≥` | Pop the top two values (a, b) and push 1 if a ≥ b, 0 otherwise. |
`d` | Duplicate the top value on the stack. |
`#` | Pop and discard the top value (send to the hard drive in the sky). |
`s` | Switch between layers A and B. |
`h` | Halt program execution. |
`w` | Begin a while loop, executing while the top of the stack is not 0 or an empty string. |
`e` | End of a loop. |
`f` | Begin an if statement, executing if the top of the stack is 1. |
`E` | Begin an else statement. |
`l` | Begin an elif statement. |
`g` | Pop top 2 on stack, goto (a,b) on the current layer. |
`*` | Input a value (string or integer) and push it onto the stack. |
`p` | Print the top value on the stack. |
Example Programs
Truth Machine
Layer A: *wpev p h Layer B: Empty.
Switchy Unleashed
Switchy! Unleashed is an extension of Switchy! that removes the 10x10 grid limitation, allowing for infinite grid size. It retains the two-layered structure and the core command set of Switchy!. This extension provides greater flexibility and potential for more complex programs.