Welcome to the Pancode tutorial! If you're reading this, you're probably at least a little interested in esoteric programming languages. If you're looking for a language to use for your next big production project, then you should probably keep looking. If you're a project manager and your developers sent you to this page, then you're either being pranked or they're very confused. Pancode is a language made for fun. It's probably not even that great for golfing, at least if you're counting bytes rather than characters.
Pancode is an esoteric stack-based programming language designed to heavily utilize many of the Unicode glyphs. If you're editing your code in the online interpreter, then there are several keyboard shortcuts for inputting the many characters used in this language. When you see a Unicode character mentioned in this documentation, mouse-over it to see how to input it in the online interpreter.
First, let's start with everybody's favorite: the obligatory Hello World program.
"Hello, world!" .
You can copy this line of code over to the interpreter and hit "Run" (or press SHIFT+ENTER in the code box). You should see the output "Hello, world!" at the bottom of the screen.
As already mentioned, Pancode is a stack-based language. That
means that all commands run on a global value stack. In
particular, the above snippet has two such commands. The first
is a literal string "Hello, world!"
which pushes
itself onto the stack when run, and the second .
is
a built-in which pops and prints the top value of the stack.
Okay, that's pretty basic. Let's talk numbers. Any good language needs a way to work with numbers. In Pancode, any literal integer, possibly preceded by a minus sign, is a literal number command which pushes itself when executed.
1 2 3 . . .
The above snippet prints 3, 2, and 1 on separate lines. Note
that the values are printed in reverse, since .
pops
the top value of the stack each time, and the top value is the
most recently pushed value. Also, you can simply remove the three .
from
the end of the snippet and run it.
1 2 3
Now you won't see any output, but you'll instead see the three values in the "Final Stack" section below the code. This is useful for debugging purposes, as the final stack will print out even if your program crashes with an error.
Pancode has all of the usual arithmetic functions. +
pops
two numbers and pushes their sum, and -
pops two
numbers and pushes their difference. In the spirit of showing
Unicode some love, Pancode uses ×
for
multiplication and ÷
for division. You can input ×
by
typing \times
, and you can input ÷
by typing \div
.
As a side note, if you're comfortable with APL, you can also in
many cases use shortcuts derived from APL. Generally, if Pancode
uses a character that appears on an APL keyboard, you can type
it in the Pancode editor by preceding the APL key with a dot.
So, for instance, ×
appears on the -
key
on an APL keyboard, so you can type it with .-
.
Likewise, you can get ÷
with .=
. If
you're not familiar with APL, you'll probably be more
comfortable with the LaTeX-style backslash shortcuts.
Let's do some arithmetic. Let's calculate (3 + 4) × (2 - 3)
3 4 + 2 3 - ×
Your final stack should be -7
. Note that
stack-based arithmetic starts to resemble reverse Polish
notation. In particular, we don't need any parentheses anymore
to disambiguate operator order.