Skip to content

Instantly share code, notes, and snippets.

@AMiller42
Last active October 22, 2021 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AMiller42/5c30657b7132bd20cbf06c55d6f39eae to your computer and use it in GitHub Desktop.
Save AMiller42/5c30657b7132bd20cbf06c55d6f39eae to your computer and use it in GitHub Desktop.

I've come up with an idea for a new esolang, called "StackAttack".

It is a stack-based language with an unusual twist: You can create and destroy stacks whenever you want.

Here's how it works:

When the program starts, it is given a number of stacks. The number is an integer, and is the number of stacks that are created. (For example, if the number is 3, then 3 stacks are created.) Each stack has a pointer to its top (its head) and a pointer to its bottom (its tail). The pointer to the top of the stack is always at position 0 in the stack. The pointer to the bottom is at the bottom of the stack.

Each command does something different to each stack, and you can switch between active stacks with the "swap" command.

When the program starts, the "stack pointer" is set to zero. When the stack pointer points to the top of a stack, that stack is the active stack. Otherwise, the stack pointer is not pointing at any stack, and the active stack is the temporary stack.

When a command is given, the command is copied to the temporary stack. You can execute the temporary stack at any time. When executed, each command in the temporary stack is run, and the temporary stack is destroyed.

When you switch the active stack, the stack pointer points to the top of one of the stacks. You can use any stack at any time.

When you switch from the temporary stack to an actual stack, the commands running in the temporary stack apply to that stack.

Also, you can have multiple stack pointers, meaning you can run commands on multiple stacks at the same time , or you could have the same command run multiple times on the same stack. You could even create a temporary stack for each command, and execute the commands simultaneously on each stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment