Skip to content
urkerab edited this page Dec 22, 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.
I/X Current cursor x-position.
J/Y Current cursor y-position.

Unary

Operator Verbose Returns
± Negate -x. Vectorizes.
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. Vectorizes.
Uppercase The uppercase equivalent of x if it has one. Vectorizes.
Minimum/min/Floor The minimum value in x, or the floor of x if it is a number.
Maximum/max/Ceiling/ceil The maximum value in x, or the ceiling of x if it is a number.
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.
GetVariable/getvar The value of the variable x.
Repeated Wolfram pattern-matching construct matching one or more of x.
RepeatedNull Wolfram pattern-matching construct matching zero or more of x.
Slice A new iterable containing the elements of x, if this is implemented in the underlying Python class.
Range Range from 0 to x, excluding x.
…· InclusiveRange Range from 0 to x, including x.
BitwiseNot The 2's complement of x.
Absolute/abs abs(x). Vectorizes.
Σ 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, casting if it is a string. Vectorizes.
Decremented/-- x-1, casting if it is a string. Vectorizes.
Doubled/*** x*2, casting if it is a string. Vectorizes.
Halved/\\ x/2, casting 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.
Rule Wolfram equivalent of named argument. Also used as match-replacement pair.
DelayedRule Lazily evaluated rule, currently does nothing.
PatternTest Wolfram pattern-matching construct. Matches x only when y returns truthy.
Slice Every item of x starting at index y.
Any True if y returns truthy for any element in x else False.
All True if y returns truthy for all elements in x else False.

Ternary

Operator Verbose Returns
Slice Every item of x starting at index y until (but not including) index z.

Quaternary

Operator Verbose Returns
Slice Every a items of x starting at index y until (but not including) index 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 ικλμνξπρςστυφχψωαβγδεζηθ.
EvaluateVariable/evalvar exp lst Runs the function in the variable x with y as its arguments.
EvaluateVariable/evalvar exp exp evalvar with y as its sole argument.
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