We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Stackfest

From Esolang
Jump to navigation Jump to search

Stackfest is a stack-based esolang by User:Cordership.

Commands

Basic syntax

Command Definition
pop from [stackname] as [variable] Pop top of stack and set it to a variable's value. Walrus operator.
push [blah blah blah] into [stackname] Push a variable, a number, or a character/string (as its ASCII value(s)).
add in [stackname] Pop values a and b, push the result of a+b.
subtract in [stackname] Pop values a and b, push the result of b-a.
mult in [stackname] Pop values a and b, push the result of a*b.
intdiv in [stackname] Pop values a and b, push the result of b/a, rounded down. If a=0 then the result is the user input.
modulo in [stackname] Pop values a and b, push the result of the integer division b/a.
exp in [stackname] Pop values a and b, push the result of b^a.
outint from [stackname] Pop top of stack and output it as integer.
outascii from [stackname] Pop top of stack and output it as an ASCII character.
push inchar into [stackname] Receive character from user and push it into the stack.
push inint into [stackname] Receive integer from user and push it into the stack.
# Comment.
null Empty stack.
discard in [stackname] Pop top of stack and discard.
[stackname] = >blah...> Sets the stack.
[variable] = blah blah ... Sets variable to a value.
[stackname] Refers to the stack.
" Toggle stringmode.
reverse in [stackname] Reverse the order of all the elements in the stack.
end End program.

Relational operations and control flow

Same as Python.

True-false booleans

Also same as Python.

Randomess

There is only one command for randomness: rand(a, b) It's the same as Python's random.randint(a, b).

The additional operations

Peek

Nothing.

Drop

discard in [stackname]

Dup

pop from [stackname] as a
push a into [stackname]
push a into [stackname]

Swap

pop from [stackname] as a
pop from [stackname] as b
push a into [stackname]
push b into [stackname]

Over

pop from [stackname] as a
pop from [stackname] as b
push b into [stackname]
push a into [stackname]
push b into [stackname]

Rotate

pop from [stackname] as a
pop from [stackname] as b
pop from [stackname] as c
push a into [stackname]
push c into [stackname]
push b into [stackname]

Rotate CCW

pop from [stackname] as a
pop from [stackname] as b
pop from [stackname] as c
push b into [stackname]
push a into [stackname]
push c into [stackname]

Examples

Hello, World!

st = >>
push "!dlroW ,olleH" into st
while st != null:
    outascii from st

Cat program

st = >>
inchar in st
while st != null:
    outascii from st
    inchar in st

A+B problem

st = >>
inint in st
inint in st
add in st
outint from st

4-function calculator

st = >>
inint in st
inint in st
inint in st
pop from st as n
if n == 1:
    add in st
    outint from st
if n == 2:
    subtract in st
    outint from st
if n == 3:
    mult in st
    outint from st
if n == 4:
    intdiv in st
    outint from st

NotDeadfish interpreter

stack1 = >>
a = 0
for x in inchar:
    push x into stack1
reverse in stack1
while stack1 != null:
    pop from stack1 as t
    match t:
        case "i":
            push a into stack1
            push 1 into stack1
            add in stack1
            pop from stack1 as a
        case "d":
            push a into stack1
            push 1 into stack1
            subtract in stack1
            pop from stack1 as a
        case "s":
            push a into stack1
            push 2 into stack1
            exp in stack1
            pop from stack1 as a
        case "o":
            push a into stack1
            outint from stack1
        case "h":
            end

Looping counter

a = 1
stk = >>
while 1:
    for _ in range (a):
        push 42 into stk
    while stk != null:
        outint from stk
    push a into stk
    push 1 into stk
    add in stk
    pup from stk as a