Gol><> Online Interpreter (v0.4.2 dev)

Note: Gol><> is still evolving, so some behaviours/syntax may change in future updates (P.S. AJAX coming some day)

Show full error
Symbolic debug


<space>     NOP
<^>v        Set IP direction  
#/\         Mirrors
.           Pop y, x and jump to (x, y)
T           Set teleport pad, saving direction
t           Teleport to last teleport pad, default (-1, 0)
x           Random direction

Control flow

!           Trampoline: add 1 to skip count
?           Pop and execute next if truthy, else skip 1
E           If the last input read lead to EOF, pop and execute next,
            else skip 1
J           Conditional jump: pop cond, y, x and jump to (x, y) if cond
q           Pop and execute next if truthy, else skip 2
Q           Pop and execute next if truthy, else skip past matching |
Z           Pop and execute next if zero/falsy, else skip 1

Note: S-instructions count as a single command for the purposes of skipping

Value pushing

"'          String parsing - push chars until closing quote
            Backtick escapes "`nr and '`nr respectively
0-9         Push 0-9 respectively
a-f         Push 10-15 respectively
l           Push length of stack
m           Push -1
s           +16 (useful for getting 17-31)
`           Escape next to char, pushing to stack
S1          Push phi ~ 1.618033
S2          Push e ~ 2.71828
S3          Push pi ~ 3.14159
Si          Push i = sqrt(-1)
Sx          Push random float in [0, 1)


;           Halt with no output
H           Halt and output stack as char until empty
h           Halt and output top of stack as num


I           Read next int/float. Push -1 on EOF.
i           Read char. Push -1 on EOF.
SE          Push 1 if last input read lead to EOF, else 0
            (see E for the conditional version)

N           Output as num + trailing newline
n           Output as num
Sn          Pop d, n and output n rounded to d decimal places
o           Output as char
S"          Like " but prints chars instead of pushing

Stack manipulation

$           Swap two
:           Duplicate
@           Rotate 3, moving 3rd down to top
K           Multiple copy: Pop n and copy the top n elements
k           Get nth element down (top is 0). Indices wrap.
r           Reverse stack
{}          Shift stack left/right
~           Pop and discard

Basic mathematical operators

+-*         Addition/subtraction/multiplication respectively
%           Modulo (always non-negative)
,           Floating point division
S,          Integer division
(=)         Less than/equals/greater than respectively
M           Minus 1
X           Exponentiation
P           Plus 1
z           Is zero/NOT: Push 1 if zero, else 0
S& S| S^    Bitwise AND, OR, XOR respectively

Other mathematical operators

S%          GCD
S( S= S)    Floor/round/ceiling respectively
S< S>       Min/max of two elements respectively
SA          Absolute value
SD          Divmod: Pop b,a and push a//b, a%b
SL          Pop b,a and push log(a,b)
SP          Primality test
ST          Three char trig functions:
              STS/STC/STT/ST2  (asin, acos, atan, atan2)
              STs/STc/STt      (sin, cos, tan)
              STh              (hypot)
              STd/STr          (to_degrees/to_radians)


B           Break - used in loops and functions
C           Continue loop
L           Loop counter for W/F, starts at zero. Refers to last loop
            if pushed outside of loop.
F           For loop - pop n and loop n times.
W           If wW, while-cond loop that pops condition.
            If no matching w, simple while loop that keeps condition.
w           Modifies matching W to be while(cond) + pops condition.
|           End of if/loop instruction

Note: Loops preserve position and direction. On completion, the IP moves to after the matching | on the same row.

Stack tape

y u         Move left/right on the stack tape, respectively

Note: & (register) is tied to each individual stack

Miscellaneous operators

&           Save to register/push from stack-based register
D           Debug, outputting stack to STDOUT.
A           Pops y and saves [-1, y] as the start of a function, direction east.
            Function name is determined by next char.
            Use B to break/return from function.
R           Pop n, repeat next instruction n times
S           Switch: Toggle next instruction
V           Pops element and re-pushes it. Saves element to variable 
            with name determined by next char.
g           Pop y, x and push char at (x, y)
p           Pop y, x, char and put char at (x, y)
Sl          Lowercase
Su          Uppercase
j           Pop x and push x to the "closure stack", to be pushed every
            iteration for the next function/loop.

Note: S should be avoided as a function/variable name