Operators
Just as a sentence means nothing without a verb, anything you write in RuLa means nothing without operators. They make it possible for a variable to be defined, for a condition to work and for a rule to make sense.
The operators below are grouped by category, and listed alphabetically within each category. For a more extensive description of each individual operator, plus examples, click on it or visit the sub-pages in the menu on the left.
Boolean Operators
| Operator |
Description |
=, !=, <, <=, >, >= |
Perform basic comparisons. Evaluate to either true or false. |
and |
Sets as condition that both expressions have to be true to have the entire expression evaluate to 'true'. |
and then |
Similar as above, but when using 'and then', the second question is only asked when the first evaluates to 'true'. |
falsy (new in Atfinity 17) |
Coerces a value to a boolean, returning true only for false, 0, "0", or "false". |
matches (=~) |
Checks if a string matches a regular expression. |
not |
A negation. |
or |
When just one of the two given expressions is true, the entire expression evaluates to 'true'. |
or else |
Similar to above, but the second question is only asked if the first has been answered. |
truthy (new in Atfinity 17) |
Coerces a value to a boolean, returning true only for true, 1, "1", or "true". |
Mathematical Operators
| Operator |
Description |
+, -, /, *, % |
Perform basic mathematical calculations. |
AVG |
Calculates the average value. |
CEIL |
Returns the value of the given parameter, rounded up to a whole number. |
CLAMP |
Clamps a numeric value between a minimum and maximum. |
COMB |
Returns the number of ways to choose k items from n items (n choose k). |
FLOOR |
Returns the value of the given parameter, rounded down to a whole number. |
MAX |
Returns the highest value. |
MIN |
Returns the lowest value. |
ROUND |
Returns the value of the given parameter, rounded to a whole number. |
SQRT |
Returns the square root of a number. |
SUM |
Adds up numbers. |
SUM_PRODUCT |
Multiplies values in one list with values on the same index in another list. Returns the sum of the multiplications. |
Date Operators
| Operator |
Description |
ADD_DAYS |
Takes a date and adds a specified number of days to it. |
ADD_MONTHS |
Takes a date and adds a specified number of months to it. |
ADD_WEEKDAYS |
Takes a date and adds a specified number of weekdays (Mon–Fri), skipping weekends. |
ADD_YEARS |
Takes a date and adds a specified number of years to it. |
AFTER |
Takes two dates, and checks if the first one comes after the second one. |
AFTER_EQUAL |
Takes two dates, and checks if the first one comes after, or is the same as, the second one. |
BEFORE |
Takes two dates, and checks if the first one comes before the second one. |
BEFORE_EQUAL |
Takes two dates, and checks if the first one comes before, or is the same as, the second one. |
DATE_EQUAL |
Returns true if two dates refer to the same calendar date, ignoring time. |
DATETIME_EQUAL |
Returns true if two datetime values refer to the exact same point in time. |
DAYS_AGO |
Returns the number of days since a given date. |
DAYS_BETWEEN |
Returns the number of days between two dates. |
DAYS_SPENT_IN_STATE |
Returns the number of days the current case has spent in a given state. |
FORMAT_DATE |
Formats a date as a human-readable string using a format pattern. |
FORMAT_DATETIME |
Formats a datetime value as a human-readable string using a format pattern. |
HOURS_BETWEEN |
Returns the number of hours between two datetime values. |
HOURS_SPENT_IN_STATE |
Returns the number of hours the current case has spent in a given state. |
IS_DATE |
Returns true if the given value can be parsed as a valid date or datetime. |
IS_WEEKDAY |
Returns true if the date falls on a Monday through Friday. |
IS_WEEKEND |
Returns true if the date falls on a Saturday or Sunday. |
MONTHS_AGO |
Returns the number of months since a given date. |
NOW |
Current date and time. |
QUARTER_OF |
Returns the quarter (1–4) of the year for a given date. |
SUBTRACT_YEARS |
Takes a date and subtracts a specified number of years from it. |
TODAY |
The current date. |
WEEKDAYS |
Returns the number of weekdays (Mon–Fri) between two dates. |
YEARS_AGO |
Calculates the number of years since a given date. |
String Operators
| Operator |
Description |
calculated_name |
Accesses the calculated name of an instance. |
CONCAT |
Combines two values into one new value, specifying what should separate the two. |
ENDS_WITH |
Returns true if a string ends with the given suffix. |
format |
Takes a string template and replaces named placeholders with provided values. |
JOIN |
Combines a list of values into one new value by appending them. |
LEFT |
Returns the first n characters (or elements) from a string or list. |
LEN |
Returns the length of a string, list, or dictionary. Alias for COUNT. |
LEVENSHTEIN |
Returns the number of single-character edits needed to transform one string into another. |
LOWER |
Converts a string to lowercase. |
MAKE_FILENAME |
Converts a string into a safe filename. |
MARKDOWN_TABLE |
Renders a list of dictionaries as a Markdown table. |
PAD_LEFT |
Pads a string on the left to the given width. Default fill is a space. |
PAD_RIGHT |
Pads a string on the right to the given width. Default fill is a space. |
REPLACE |
Replaces all occurrences of a value in a string with another value. |
REPLACE_CHARS |
Replaces characters in a string one-for-one using two equal-length character sequences. |
RIGHT |
Returns the last n characters (or elements) from a string or list. |
SLICE |
Returns a portion of a string or list between a start and end index. |
SPLIT |
Splits a string by a separator into a list. Optional max splits. |
STARTS_WITH |
Returns true if a string starts with the given prefix. |
STRING_TO_JSON |
Parses a JSON-encoded string and returns the corresponding dictionary or list. |
TRANSLATE_STRING |
Returns a translation marker for a custom string key, resolved at render time. |
TRIM |
Removes whitespace (or specified characters) from the beginning and end of a string. |
TRIM_LEFT |
Removes whitespace (or specified characters) from the beginning of a string. |
UPPER |
Converts a string to uppercase. |
UUID |
Generates a random UUID string. |
List Operators
| Operator |
Description |
[] |
Creates a new list from single values, allowing other list operators to perform actions on the new list. |
[] |
Accesses an element of a list by its zero-based index. |
ALL |
Evaluates if all values in a list are true. |
ANY |
Evaluates if at least one value in a list is true. Alias for SOME. |
APPEND |
Returns a new list with a single element appended to the end. Does not mutate the original. |
contains |
Goes over a list, which is given on the left of the operator. Evaluates to 'true' if the single value on the right is present in the given list. |
contains all |
Expressions with this operator will only evaluate to 'true' if all values from the list on the right side are present in the list on the left side. |
contains any |
Going over a list, given on the left side of the operator, this operator has the expression evaluate to true if any value from that list is present in a list or the single value given on the right side. |
COUNT |
Returns the length of a list, dictionary, or string. Alias for LEN. |
CUSTOM_MAX |
Returns the maximum element in a list as ranked by a second ordering list. |
FILTER |
Removes all occurrences of a specified value from a list. |
filter() |
Applies a conditional expression to a list, keeping only elements where the condition is true. |
FILTER_FALSE |
Removes all false elements from the provided arguments. |
FILTER_UNKNOWN |
Removes all unknown values from a list. |
FIRST_ELEMENT |
Returns the first element from a list. |
FLATTEN |
Extracts values from a list of dictionaries by key, or concatenates a list of lists into a single list. |
in |
Checks if a value is present in a taxonomy. |
INDEX_OF |
Returns the index of the first occurrence of a value in a list or string. Returns -1 if not found. |
INTERSECTION |
Returns the elements that appear in both lists. |
LAST_ELEMENT |
Returns the last element from a list. |
MAP |
Performs the same action on each individual value in a list. |
map() |
Performs the same action on each individual value in a list using method syntax. |
not in |
Evaluates to true if the given value is absent from the specified taxonomy. |
REVERSE |
Reverses the order of elements in a list. |
SET |
Removes duplicates from a list. |
SET_DIFFERENCE |
Returns the elements in the first set that are not in the second set. |
SOME |
Evaluates if any value in a list is true. |
SORT |
Sorts a list. |
UNION |
Combines the elements of two sets into one single set. |
Dictionary Operators
| Operator |
Description |
{} |
Creates a new dictionary from key-value pairs, allowing other dictionary operators to perform actions on the new dictionary. |
Special Operators
| Operator |
Description |
:= |
Assignment, which can have any kind of expression on the right side of the operator. |
ensure |
Makes sure a case contains at least, for example, 1 Person. (replaces create) |
get_attr |
Gives access to named properties of an instance using expressions. |
get_properties |
Returns specific information on an instance's properties. |
GET_TRANSLATED_ATTR |
Like get_attr, but returns the translated display value of the attribute. |
has_attr |
Returns true if an instance has a given attribute defined. |
instances |
Returns all instances of the given type(s) living on the platform. |
instances_exist |
Returns true if the case has at least one instance of the specified type(s). |
is |
Basic assignment of a variable. |
IS_UNIQUE_NAME |
Returns true if no active instance of the given type with that name exists. |
NAME_AND_LOG |
Evaluates an expression, logs its result under a name for debugging, and returns the result unchanged. |
ontology |
Sets a condition based on the type of ontology. |
PICK_OR_DEFAULT |
Returns a value from an allowed list if it matches the input, otherwise returns a default. |
PRETTY_PRINT |
Formats a dictionary or list as an indented, human-readable JSON string. |
roles |
Sets a condition based on role(s). |
self |
Refers to the current instance where you use it. |
Translate (.$) |
Accesses a taxonomy attribute in a way that its value is translated into the requested language at render time. |
Unknown Operators (Three-Valued Logic)
| Operator |
Description |
AVG_OF_ANY |
Calculates the average of available values. |
CONCAT_OF_ANY |
Like CONCAT, but only combines the values that are available (not unknown). |
JOIN_OF_ANY |
Like JOIN, but only joins the values that are available (not unknown). |
known |
Sets a condition for when a property is not unknown. |
LIST_OF_ANY |
Builds a list of only the values that are available out of all the values it is given. |
MAX_OF_ANY |
Returns the highest out of available values. |
MIN_OF_ANY |
Returns the lowest out of available values. |
SNEAKY |
Wrapping an expression with SNEAKY has the system ignore the expression, if the information used in it is not available. |
SUM_OF_ANY |
Adds available numbers. |
UNION_OF_ANY |
Creates a combined list of the available values and lists out of all values and lists you provide. |
unknown |
Sets a condition for when a property is unknown. |