Skip to content

SP-Lang Expressions¤

Expressions in SP-Lang are written as YAML tags directives.

List of expressions¤

Expression Type Category Description
!COUNT sequence aggregate Counts the number of items.
!MIN sequence aggregate Calculates the minimum from a list of items.
!MAX sequence aggregate Calculates the maximum from a list of items.
!AVG sequence aggregate Calculates the average (arithmetic mean) of items in a list.
!MEDIAN sequence aggregate Finds the median (middle value) of a list of items.
!MODE sequence aggregate Finds the value that appears most often.
!RANGE sequence aggregate Finds the difference between the highest and smallest value.
!ADD sequence arithmetic Addition.
!SUB sequence arithmetic Subtraction.
!MUL sequence arithmetic Multiplication.
!DIV sequence arithmetic Division.
!MOD sequence arithmetic Modulo.
!POW sequence arithmetic Exponentiation.
!ABS mapping arithmetic Absolute value.
!SHL mapping bitwise Left logical shift.
!SHR mapping bitwise Right logical shift.
!SAL mapping bitwise Left arithmetic shift.
!ROL mapping bitwise Circular rotation to the left.
!ROR mapping bitwise Circular rotation to the right.
!EQ sequence comparisons Equal to.
!NE sequence comparisons Not equal to.
!LT sequence comparisons Less than.
!LE sequence comparisons Less than or equal to.
!GT sequence comparisons Greater than.
!GE sequence comparisons Greater than or equal to.
!IN mapping comparisons Membership test.
!IF mapping control Simple conditional branching.
!WHEN sequence control Powerful branching.
!MATCH mapping control Pattern matching.
!TRY sequence control Execute till first non-error expression.
!MAP mapping control Apply the expression on each element in a sequence.
!REDUCE mapping control Reduce the elements of an list into a single value.
!INCLUDE scalar directives Inserts the content of another file.
!ARGUMENT scalar function Gets a function argument.
!ARG scalar function Gets a function argument.
!FUNCTION mapping function Defines a new function.
!FN mapping function Defines a new function.
!SELF mapping function Applies the current function, used for recursion.
!IP.FORMAT mapping ip Converts an IP address into a string.
!IP.INSUBNET mapping ip Check if IP address falls into a subnet.
!GET mapping json Gets a single value from JSON.
!JSON.PARSE mapping json Parses JSON.
!LIST mapping list Creates a list of items.
!GET mapping list Gets a single item from a list.
!AND sequence logic Conjunction.
!OR sequence logic Disjunction.
!NOT sequence logic Negation.
!LOOKUP mapping lookup Creates a new lookup.
!GET mapping lookup Gets items from a lookup.
IN mapping lookup Checks if an item is in a lookup.
!RECORD mapping record A collection of named items.
!GET mapping record Gets the item from a record.
!REGEX regex Regular expression search.
!REGEX.REPLACE mapping regex Regular expression replace.
!REGEX.SPLIT mapping regex Split a string by a regular expression.
!REGEX.FINDALL mapping regex Find all occurrences by a regular expression.
!REGEX.PARSE mapping regex Parse by a regular expression.
!SET mapping set Set of items.
!IN mapping set Membership test.
!IN mapping string Tests if a string contains a substring.
!STARTSWITH mapping string Tests whether a string starts with a selected prefix.
!ENDSWITH mapping string Tests whether a string ends with a selected suffix.
!SUBSTRING mapping string Extracts part of a string.
!LOWER mapping string Transforms a string into lowercase.
!UPPER mapping string Transforms a string into uppercase.
!CUT mapping string Cuts the string and returns a selected part.
!SPLIT mapping string Splits a string into a list.
!RSPLIT mapping string Splits a string from right into a list.
!JOIN mapping string Joins a list of strings.
!TUPLE mapping tuple A collection of items.
!GET mapping tuple Get item from a tuple.
!CAST mapping utility Converts type of the argument into another.
!HASH mapping utility Calculates a digest.
!DEBUG mapping utility Debugs the expression.