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 One Stack

From Esolang
Jump to navigation Jump to search

Stacckfest One Stack is a variation of Stackfest made by User:Cordership. This esolang, however, has only one stack.

Syntax

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

True-false booleans, control flow, and relational operators are the same as Python.

Programs

Hello, World!

push "!dlroW, olleH"
while stack != null:
    outascii

Looping counter

a = 1
while 1:
    for _ in range (a):
        push 42
    while stk != null:
        outint
    push a
    push 1
    add
    pop as a

Truth-machine

push inint
pop as t
if t == 0:
    push 0
    outint
    end
else:
    while 1:
        push 1
        outint

Fibonacci sequence

a = inint
b = 0
push 1
push b
for _ in range (a):
    pop as x
    pop as y
    push x
    push y
    pop as b
    push b
    add
    push b