Skip to content
Python based golf language.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Python 3 based golf language.

Pretty basic stack based language. Mostly just doing this because I want to get a better feel for how stack based languages work.

All commands operate as follows stack[-1] op stack[-2] unless otherwise specified.

Variables and constants must be defined with capital letters.

Any place you can use an integer literal, you can use a command, variable, or function.

Implicitly prints the stack at the end of the instruction set.

How to run.

py -3 program.p *args

Some examples.

"Hello, World!"c  # Hello world.
0{d1+,i}c         # Print the ascii table (0,sys.argv[0]]
i:At,{n,A}j@      # [Look and Say](
11fA..+@{A,i}     # First sys.argv[0] Fibonacci numbers

Bonus quine, all credit to kms7047


Supports the following operations:

Basic Operations

Command Result
-?\d Push the number to the stack.
#\d+# Push the number between the # marks to the stack.
+-/*% Basic arithmetic operations.
<> &^~


If the variable command is only one character, it assumes that you're operating on the stack. For example: :A1A1:A+xA == [2]

Command Result
:name(value) Creates a constant.
[name(value or command)] Create a variable. If no value is given, takes the value of the top of the stack.


Command Result
{command,count} For loop. Repeats command count times.
w(command),(condition} While loop, repeat command while condition is truthy.

Stack Commands

Command Result
q Sets the top of the stack equal to the square root of the previous top of stack.
e Set the top of the stack equal to stack[-2] ** stack[-1]
p Print the stack.
m Return the primality of the top of the stack.
c Print the stack as a string. Exits after printing.
\ Swap the top two elements of the stack.
i Take command line arguments and put them on the stack.
s Sum the stack and return it.
l Return the length of the stack.
x Clear the stack.
, Pop the top of the stack and discard it.
t Get the top of the stack.
b Get the bottom of the stack.
d Duplicate the top of the stack.
g Check if stack[-1] > stack[-2]
` Sort the stack.
v Reverse the stack.
! Returns the factorial of the top of the stack.
o Count the items in the stack. Sets the stack equal to [count, element...] for each element in the stack.
j Join and print the stack. Exits after printing.
@ Quit without printing the stack.
r Push a random int to the top of the stack.
a Get the first stack[-1] digits of pi. If the stack is empty, returns the first 100.
h Push the top of the stack to the list in stack[-2].
_ Check if the top of the stack is in the stack excluding the top.
y Zip the stack into sub lists
k Append (stack[-2]..stack[-1]) to the stack. Consumes stack[-1] and stack[-2]

Complex Commands

Command Result
;(value) Move the element of the stack in position (value) to the top of the stack.
f(name)(body)@ Create a function. Uses . for args that get replaced with the top of the stack left to right.
(values) Create a list. Any operation done on a list is done matrix wise. Ex. 1(234)-s == [6].
?(condition) If statement. If stack[-1] == condition, skip the next instruction.
@(value) Copy the element at value (zero indexed) to the top of the stack.
'(command)} Apply command to each element of the stack.

Pre-initialized Variables

The following variables have been pre-initialized to useful values.

Variable Value
A -1
B 10
C 100
D 1000
E 0
You can’t perform that action at this time.