Skip to content
E-Hern Lee edited this page Sep 6, 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.
Σ Sum The sum of all elements in x if it is an array, digital sum if it is a number, sum of all numbers or digital sum if it is a string depending on whether it can be parsed as a single number.
Π Product The product of all elements in x if it is an array, digital product if it is a number, product of all numbers or digital product if it is a string depending on whether it can be parsed as a single number.
Incremented/++ x+1 if it is a number, ... if it is a string. Vectorizes.
Decremented/++ x-1 if it is a number, ... if it is a string. Vectorizes.
Doubled/++ x*2 if it is a number, ... if it is a string. Vectorizes.
Halved/++ x/2 if it is a number, ... if it is a string. Vectorizes.
UV PythonEvaluate/pyeval eval(x).

Binary

Operator Verbose Returns
Add/Plus x+y. Vectorizes.
Subtract/Minus x-y, or x with y deleted if both x and y are strings. Vectorizes.
× Multiply/Times x*y. Vectorizes.
÷ IntDivide/IntegerDivide x//y. Vectorizes.
Divide x/y, or x split by y if x and y are strings, or x reduced using y if y is a function. Vectorizes.
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/Mold 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]). During evaluation of y, the loop variable and index are stored in the first two free variables in ικλμνξπρςστυφχψωαβγδεζηθ.
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