Skip to content
urkerab edited this page Aug 3, 2017 · 20 revisions

Operators are used to modify data and return it, for example to do arithmetic. They are classified as nilary, unary, binary or ternary depending on the number of arguments they take, and non-lazy or lazy depending on whether they take their arguments in evaluated form or non-evaluated form. There are also some operators that use their own syntax. In verbose mode they take the form of functions, similar to commands. Operands are denoted by x, y, z and a respectively.

Non-lazy

Nilary

Operator Verbose Returns
InputString The next input as a string.
InputNumber The next input as a number.
Random 0 or 1 with equal chance.
KA PeekAll Every cell on the canvas, from left to right and top to bottom.
KM PeekMoore Cells in a Moore neighborhood around the cursor
KV PeekVonNeumann Cells in a Von Neumann neighborhood around the cursor.
KK Peek The character under the cursor.

Unary

Operator Verbose Returns
± Negate -x.
Length The length of x.
¬ Not False if x is truthy, else True if x is falsy.
Cast x as a string if it is a number, or x as a number if it is a string.
Random A random integer between 0 and x, each number having equal chance to appear, or a randomly selected character if x is a string or a random element if x is a list.
Evaluate/eval The result after executing x as a string.
Pop The last value in x, after removing it from x.
Lowercase The lowercase equivalent of x if it has one.
Uppercase The uppercase equivalent of x if it has one.
Minimum The minimum value in x.
Maximum The maximum value in x.
Character/Ordinal/chr/ord The character code of x if x is a character, or the character x is the character code of if x is an integer.
Reverse x reversed.
BitwiseNot The 2's complement of x.

Binary

Operator Verbose Returns
Add/Plus x+y.
Subtract/Minus x-y, or x with y deleted if both x and y are strings.
× Multiply/Times x*y.
÷ IntDivide/IntegerDivide x//y.
Divide x/y.
Modulo x%y. Note that this can be used to format strings.
Equals Whether x is equal to y.
Less <
Greater >
…· InclusiveRange [x, y] over the integers or characters.
Range [x, y) over the integers or characters.
CycleChop x repeated and chopped to length y.
Exponentiate/Exponent/Power x to the power of y.
§ AtIndex x[y], wrapping if needed.
⊞O PushOperator x after pushing y to x.
Join The result of joining x with y.
Split The result of splitting x with y.
⌕A FindAll The indices of y in x.
Find The index of y in x.
PadLeft The result of left-padding x with y.
PadRight The result of right-padding x with y.
Count The number of occurrences of y in x.

Quaternary

Operator | Verbose | Returns | Slice | Every a items of x starting at y until (but not including) z.

Lazy

Binary

Operator Verbose Returns
And/and y if x and y are both truthy else False. Short-circuits.
Or/or y if y is truthy, else x if x is truthy, else False. Short-circuits.

Ternary

Operator Verbose Returns
Ternary y if x is truthy else z.

Other

Operator Verbose Arguments Returns
KD PeekDirection exp dir The cells in a line of length x in the direction y from the cursor, including the cell under the cursor.
Each/Map exp exp An array arr where arr[i] is y(x[i]).
UP PythonFunction str lst Gets the function with a return value x from Python, and runs it with y as arguments.
Clone this wiki locally