Expression functions

Extend your transaction monitoring rules with expression functions.

Expression functions allow you to extend your rule conditions enabling more precise transaction monitoring.

Below is a list of available expression functions, grouped by purpose. You can use these functions to build SumScript expressions.

📘

Note

For guidance on creating more complex conditions, see Advanced usage.

Array operations

Use these functions to perform operations on arrays.

arrayAvg

arrayAvg(array: NUMBER[]) → FLOAT NOT NULL

Returns the arithmetic mean of the values in a numeric array.

Arguments

NameTypeDescription
arrayNUMBER[]Numeric array.

Returns

TypeDescription
FLOAT NOT NULLNumeric result.

arrayCount

arrayCount(filter: (V) ->BOOL, array: V[]) → INT NOT NULL

Counts the elements in an array that satisfy the predicate.

Arguments

NameTypeDescription
filter(V) ->BOOLPredicate applied to each element (returns true to count the element).
arrayV[]Input array.

Returns

TypeDescription
INT NOT NULLResulting integer value.

arrayFilter

arrayFilter(filter: (V) ->BOOL, array: V[]) → V[]

Filters an array by applying the predicate function to each element.

Arguments

NameTypeDescription
filter(V) ->BOOLPredicate applied to each element (returns true to keep the element).
arrayV[]Input array.

Returns

TypeDescription
V[]Resulting array.

arrayJoin

arrayJoin(source: V[]*) → V*

Concatenates arrays/streams into a single stream.

Arguments

NameTypeDescription
sourceV[]*Arrays/streams to concatenate.

Returns

TypeDescription
V*Result value.

arrayMap

arrayMap(fn: (V) ->R, array: V[]) → R[]

Maps an array by applying the function to each element.

Arguments

NameTypeDescription
fn(V) ->RMapping function applied to each element.
arrayV[]Input array.

Returns

TypeDescription
R[]Resulting array.

arrayMax

arrayMax(array: V : COMPARABLE[]) → V : COMPARABLE

Returns the maximum element of the array.

Arguments

NameTypeDescription
arrayV : COMPARABLE\[]Comparable array.

Returns

TypeDescription
V : COMPARABLENumeric result.

arrayMin

arrayMin(array: V : COMPARABLE[]) → V : COMPARABLE

Returns the minimum element of the array.

Arguments

NameTypeDescription
arrayV : COMPARABLE[]Comparable array.

Returns

TypeDescription
V : COMPARABLENumeric result.

arraySlice

arraySlice(array: V[], offset: INT NOT NULL, length: INT) → V[]

Returns a slice of an array starting at the given offset (and optional length).

Arguments

NameTypeDescription
arrayV[]Input array.
offsetINT NOT NULLZero-based start index.
lengthINTMaximum number of elements to return.

Returns

TypeDescription
V[]Resulting array.

arrayStddevSamp

arrayStddevSamp(array: NUMBER[]) → FLOAT NOT NULL

Returns the sample standard deviation of the numeric array.

Arguments

NameTypeDescription
arrayNUMBER[]Numeric array.

Returns

TypeDescription
FLOAT NOT NULLNumeric result.

arraySum

arraySum(value: INT[]) → INT NOT NULL
arraySum(value: FLOAT[]) → FLOAT NOT NULL

Returns the sum of the numeric array.

Arguments

NameTypeDescription
valueINT[] | FLOAT[]Numeric array.

Returns

TypeDescription
INT NOT NULL | FLOAT NOT NULLNumeric result.

countEqual

countEqual(array: V[], value: V) → INT NOT NULL

Counts how many elements in the array are equal to the given value.

Arguments

NameTypeDescription
arrayV[]Input array.
valueVValue to compare against.

Returns

TypeDescription
INT NOT NULLResulting integer value.

empty

// Returns `true` if the string is null or empty.

empty(s: STRING) → BOOL NOT NULL
// Returns `true` if the array is empty.

empty(array: V[]) → BOOL NOT NULL

Arguments

NameTypeDescription
s | arraySTRING | V[]Parameter.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

flatten

flatten(array: V[][]) → V[]

Flattens a 2D array into a 1D array.

Arguments

NameTypeDescription
arrayV[][]2D array to flatten.

Returns

TypeDescription
V[]Resulting array.

has

has(array: V[], value: V) → BOOL NOT NULL

Returns true if the array contains the given value.

Arguments

NameTypeDescription
arrayV[]Input array.
valueVValue to look for.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

hasAll

hasAll(array1: V[], array2: V[]) → BOOL NOT NULL

Returns true if array1 contains all elements from array2.

Arguments

NameTypeDescription
array1V[]First array.
array2V[]Second array.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

hasAny

hasAny(array1: V[], array2: V[]) → BOOL NOT NULL

Returns true if array1 and array2 have at least one common element.

Arguments

NameTypeDescription
array1V[]First array.
array2V[]Second array.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

length

// Returns the number of characters in a string.

length(s: STRING) → INT NOT NULL
// Returns the number of elements in an array.

length(array: V[]) → INT NOT NULL

Arguments

NameTypeDescription
s | arraySTRING | V[]Parameter.

Returns

TypeDescription
INT NOT NULLResulting integer value.

notEmpty

// Returns `true` if the string is not null and not empty.

notEmpty(s: STRING) → BOOL NOT NULL
// Returns `true` if the array is not empty.

notEmpty(array: V[]) → BOOL NOT NULL

Arguments

NameTypeDescription
s | arraySTRING | V[]Parameter.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

Date and time (basic operations)

Use these functions to perform basic date and time operations.

diffDays

diffDays(date1: DATE, date2: DATE) → INT

Returns the difference between two dates in whole days.

Arguments

NameTypeDescription
date1DATEStart date/time value.
date2DATEEnd date/time value.

Returns

TypeDescription
INTDifference between two dates in days.

diffHours

diffHours(date1: DATE, date2: DATE) → INT

Returns the difference between two dates in whole hours.

Arguments

NameTypeDescription
date1DATEStart date/time value.
date2DATEEnd date/time value.

Returns

TypeDescription
INTDifference between two dates in hours.

diffMinutes

diffMinutes(date1: DATE, date2: DATE) → INT

Returns the difference between two dates in whole minutes.

Arguments

NameTypeDescription
date1DATEStart date/time value.
date2DATEEnd date/time value.

Returns

TypeDescription
INTDifference between two dates in minutes.

diffSeconds

diffSeconds(date1: DATE, date2: DATE) → INT

Returns the difference between two dates in whole seconds.

Arguments

NameTypeDescription
date1DATEStart date/time value.
date2DATEEnd date/time value.

Returns

TypeDescription
INTDifference between two dates in seconds.

getTimeZone

getTimeZone() → ZoneId NOT NULL

Returns the engine's current time zone.

Returns

TypeDescription
ZoneId NOT NULLTime zone identifier.

now

now() → DATE NOT NULL

Returns the current date/time.

Returns

TypeDescription
DATE NOT NULLResult value.

timeDiffMinutes

timeDiffMinutes(a: DATE, b: DATE) → INT

Returns the minimal cyclic difference between two times in minutes (wraps at 24h).

Arguments

NameTypeDescription
aDATEParameter.
bDATEParameter.

Returns

TypeDescription
INTResult value.

timeDiffSeconds

timeDiffSeconds(a: DATE, b: DATE) → INT

Returns the minimal cyclic difference between two times in seconds (wraps at 24h).

Arguments

NameTypeDescription
aDATEParameter.
bDATEParameter.

Returns

TypeDescription
INTResult value.

toDayOfWeek

toDayOfWeek(localDateTime: LOCAL_DATE_TIME) → INT

Returns the ISO day-of-week number for the given local date/time (1=Monday..7=Sunday).

Arguments

NameTypeDescription
localDateTimeLOCAL_DATE_TIMEInput local date/time value.

Returns

TypeDescription
INTResulting integer value.

toHour

toDayOfWeek(localDateTime: LOCAL_DATE_TIME) → INT

Extracts the hour of day from a local date/time (0..23).

Arguments

NameTypeDescription
localDateTimeLOCAL_DATE_TIMEInput local date/time value.

Returns

TypeDescription
INTResulting integer value.

toRelativeMinuteNum

toRelativeMinuteNum(date: DATE) → INT

Returns the minute number within the day for the given date/time (0..1439).

Arguments

NameTypeDescription
dateDATEInput date/time value.

Returns

TypeDescription
INTResulting integer value.

toRelativeSecondNum

toRelativeSecondNum(date: DATE) → INT

Returns the second number within the day for the given date/time.

Arguments

NameTypeDescription
dateDATEInput date/time value.

Returns

TypeDescription
INTResulting integer value.

toTime

toTime(date: DATE) → DATE

Converts the input date/time value to the engine's DATE type.

Arguments

NameTypeDescription
dateDATEParameter.

Returns

TypeDescription
DATEResult value.

Date and time (period boundaries)

Use these functions to perform date and time operations related to period boundaries.

startOfMonth

startOfMonth(offset: INT NOT NULL) → DATE NOT NULL

Returns the start of the month for the current date shifted by the given month offset.

Arguments

NameTypeDescription
offsetINT NOT NULLMonth offset relative to the current month (can be negative).

Returns

TypeDescription
DATE NOT NULLA date/time value truncated/adjusted to the requested boundary.

startOfYear

startOfYear(offset: INT NOT NULL) → DATE NOT NULL

Returns the start of the year for the current date shifted by the given year offset.

Arguments

NameTypeDescription
offsetINT NOT NULLYear offset relative to the current year (can be negative).

Returns

TypeDescription
DATE NOT NULLA date/time value truncated/adjusted to the requested boundary.

toLastDayOfMonth

toLastDayOfMonth(date: V : DATE) → V : DATE

Returns a date/time value moved to the last day of the month.

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

toStartOfDay

toStartOfDay(date: V : DATE) → V : DATE

Truncates a date/time value to the start of the day (00:00:00).

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

toStartOfHour

toStartOfHour(date: V : DATE) → V : DATE

Truncates a date/time value to the start of the hour (minutes/seconds set to zero).

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

toStartOfMonth

toStartOfMonth(date: V : DATE) → V : DATE

Truncates a date/time value to the first day of the month (start of day).

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

toStartOfWeek

toStartOfWeek(date: V : DATE) → V : DATE

Truncates a date/time value to the start of the week.

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

toStartOfYear

toStartOfYear(date: V : DATE) → V : DATE

Truncates a date/time value to the first day of the year (start of day).

Arguments

NameTypeDescription
dateV : DATEInput date/time value.

Returns

TypeDescription
V : DATEA date/time value truncated/adjusted to the requested boundary.

Date and time (relative offsets)

Use these functions to perform date and time operations with relative offsets.

days

days(value: INT NOT NULL) → DURATION NOT NULL

Creates a duration representing the given number of days.

Arguments

NameTypeDescription
valueINT NOT NULLAmount of days.

Returns

TypeDescription
DURATION NOT NULLA duration value.

daysAgo

daysAgo(value: INT NOT NULL) → DATE NOT NULL

Returns the date/time that is the given number of days before now.

Arguments

NameTypeDescription
valueINT NOT NULLOffset in days.

Returns

TypeDescription
DATE NOT NULLA date/time value representing now minus the specified offset.

hours

hours(value: INT NOT NULL) → DURATION NOT NULL

Creates a duration representing the given number of hours.

Arguments

NameTypeDescription
valueINT NOT NULLAmount of hours.

Returns

TypeDescription
DURATION NOT NULLA duration value.

hoursAgo

hoursAgo(value: INT NOT NULL) → DATE NOT NULL

Returns the date/time that is the given number of hours before now.

Arguments

NameTypeDescription
valueINT NOT NULLOffset in hours.

Returns

TypeDescription
DATE NOT NULLA date/time value representing now minus the specified offset.

minutes

minutes(value: INT NOT NULL) → DURATION NOT NULL

Creates a duration representing the given number of minutes.

Arguments

NameTypeDescription
valueINT NOT NULLAmount of minutes.

Returns

TypeDescription
DURATION NOT NULLDuration value.

minutesAgo

minutesAgo(value: INT NOT NULL) → DATE NOT NULL

Returns the date/time that is the given number of minutes before now.

Arguments

NameTypeDescription
valueINT NOT NULLOffset in minutes.

Returns

TypeDescription
DATE NOT NULLA date/time value representing now minus the specified offset.

monthsAgo

monthsAgo(value: INT NOT NULL) → DATE NOT NULL

Returns the date/time that is the given number of months before now.

Arguments

NameTypeDescription
valueINT NOT NULLOffset in months.

Returns

TypeDescription
DATE NOT NULLA date/time value representing now minus the specified offset.

seconds

seconds(value: INT NOT NULL) → DURATION NOT NULL

Creates a duration representing the given number of seconds.

Arguments

NameTypeDescription
valueINT NOT NULLAmount of seconds.

Returns

TypeDescription
DURATION NOT NULLA duration value.

weeksAgo

weeksAgo(value: INT NOT NULL) → DATE NOT NULL

Returns the date/time that is the given number of weeks before now.

Arguments

NameTypeDescription
valueINT NOT NULLOffset in weeks.

Returns

TypeDescription
DATE NOT NULLA date/time value representing now minus the specified offset.

Fuzzy matching

Use these functions to perform operations based on fuzzy matching.

fuzzyMatchExact

fuzzyMatchExact(str1: STRING, str2: STRING) → BOOL NOT NULL

Returns true if the normalized Levenshtein similarity of the strings is 1. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.

Arguments

NameTypeDescription
str1STRINGFirst string to compare.
str2STRINGSecond string to compare.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

fuzzyMatchStrict

fuzzyMatchStrict(str1: STRING, str2: STRING) → BOOL NOT NULL

Returns true if the normalized Levenshtein similarity of the strings is 0.9 or higher. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.

Arguments

NameTypeDescription
str1STRINGFirst string to compare.
str2STRINGSecond string to compare.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

fuzzyMatchDefault

fuzzyMatchDefault(str1: STRING, str2: STRING) → BOOL NOT NULL

Returns true if the normalized Levenshtein similarity of the two strings is 0.8 or higher. Before comparison, strings are normalized: converted to lowercase, with all special characters and redundant whitespace removed.

Arguments

NameTypeDescription
str1STRINGFirst string to compare.
str2STRINGSecond string to compare.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

fuzzyMatchFuzzy

fuzzyMatchFuzzy(str1: STRING, str2: STRING) → BOOL NOT NULL

Returns true if the normalized Levenshtein similarity of the strings is 0.6 or higher. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.

Arguments

NameTypeDescription
str1STRINGFirst string to compare.
str2STRINGSecond string to compare.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

fuzzyMatchValue

fuzzyMatchValue(str1: STRING, str2: STRING) → FLOAT NOT NULL

Returns the normalized Levenshtein similarity of the strings as a value in the range [0.0, 1.0]. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.

Arguments

NameTypeDescription
str1STRINGFirst string to compare.
str2STRINGSecond string to compare.

Returns

TypeDescription
FLOAT NOT NULLNormalized Levenshtein similarity in the range.

Geo and spatial

Use these functions to perform geo and spatial operations.

greatCircleDistance

greatCircleDistance(lat1: FLOAT, lon1: FLOAT, lat2: FLOAT, lon2: FLOAT) → FLOAT

Calculates the great-circle distance between two points on the Earth in meters.

Arguments

NameTypeDescription
lat1FLOATLatitude of the first point in decimal degrees.
lon1FLOATLongitude of the first point in decimal degrees.
lat2FLOATLatitude of the second point in decimal degrees.
lon2FLOATLongitude of the second point in decimal degrees.

Returns

TypeDescription
FLOATThe distance between two points in meters.

greatCircleDistanceRad

greatCircleDistanceRad(lat1: FLOAT, lon1: FLOAT, lat2: FLOAT, lon2: FLOAT) → FLOAT

Calculates the great-circle distance between two points on the Earth in meters.

Arguments

NameTypeDescription
lat1FLOATLatitude of the first point in radians.
lon1FLOATLongitude of the first point in radians.
lat2FLOATLatitude of the second point in radians.
lon2FLOATLongitude of the second point in radians.

Returns

TypeDescription
FLOATThe distance between two points in meters.

Map or grouping

Use these functions to perform operations based on mapping/grouping.

countBy

countBy(value: (S : OBJECT NOT NULL) ->K) → MAP<K NOT NULL, INT>

Groups elements by key and counts occurrences.

Arguments

NameTypeDescription
value(S : OBJECT NOT NULL) ->KFunction used to derive grouping keys.

Returns

TypeDescription
MAP\<K NOT NULL, INT>Resulting map.

map

map(a: STRING NOT NULL, b: V) → MAP<STRING NOT NULL, V>
map(a: INT NOT NULL, b: V) → MAP<INT NOT NULL, V>
map(a: DATE NOT NULL, b: V) → MAP<DATE NOT NULL, V>

Creates a map with a single key/value pair.

Arguments

NameTypeDescription
aSTRING NOT NULL | INT NOT NULL | DATE NOT NULLMap key/value component.
bVMap key/value component.

Returns

TypeDescription
MAP\<STRING NOT NULL, V> | MAP\<INT NOT NULL, V> | MAP\<DATE NOT NULL, V>Resulting map.

mapKeys

mapKeys(map: MAP<K : OBJECT NOT NULL NOT NULL, V>) → K : OBJECT NOT NULL[]

Returns an array containing all keys from the map.

Arguments

NameTypeDescription
mapMAP<K : OBJECT NOT NULL NOT NULL, V>Input map.

Returns

TypeDescription
K : OBJECT NOT NULL[]Resulting array.

mapValues

mapValues(map: MAP<K : OBJECT NOT NULL NOT NULL, V>) → V[]

Returns an array containing all values from the map.

Arguments

NameTypeDescription
mapMAP<K : OBJECT NOT NULL NOT NULL, V>Input map.

Returns

TypeDescription
V[]Resulting array.

sumBy

sumBy(a: (S) ->K : OBJECT NOT NULL, b: (S) ->NUMBER) → MAP<K : OBJECT NOT NULL NOT NULL, NUMBER>

Groups elements by key and sums extracted numeric values.

Arguments

NameTypeDescription
a(S) ->K : OBJECT NOT NULLFunctions used to derive grouping keys and numeric values.
b(S) ->NUMBERFunctions used to derive grouping keys and numeric values.

Returns

TypeDescription
MAP<K : OBJECT NOT NULL NOT NULL, NUMBER>Resulting map.

sumMap

sumMap(value: MAP<K : OBJECT NOT NULL NOT NULL, INT>*) → MAP<K : OBJECT NOT NULL NOT NULL, INT>
sumMap(value: MAP<K : OBJECT NOT NULL NOT NULL, FLOAT>*) → MAP<K : OBJECT NOT NULL NOT NULL, FLOAT>

Sums maps with identical keys, producing a merged map.

Arguments

NameTypeDescription
valueMAP<K : OBJECT NOT NULL NOT NULL, INT>* | MAP<K : OBJECT NOT NULL NOT NULL, FLOAT>*Input maps to sum/merge.

Returns

TypeDescription
MAP<K : OBJECT NOT NULL NOT NULL, INT> | MAP\<K : OBJECT NOT NULL NOT NULL, FLOAT>Resulting map.

Nullability and type utilities

Use these functions to perform operations based on nullability and type utilities.

exists

exists(value: V*) → BOOL

Returns true if the stream contains at least one element.

Arguments

NameTypeDescription
valueVParameter.

Returns

TypeDescription
BOOLBoolean result.

ifNull

ifNull(value: V, def: V NOT NULL) → V NOT NULL

Returns the value if it is not null, otherwise returns the default.

Arguments

NameTypeDescription
valueVInput value (may be null).
defV NOT NULLDefault value returned when input is null.

Returns

TypeDescription
V NOT NULLSelected value.

isNotNull

isNotNull(value: OBJECT) → BOOL NOT NULL

Returns true if the value is not null.

Arguments

NameTypeDescription
valueOBJECTParameter.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

isNull

isNull(value: OBJECT) → BOOL NOT NULL

Returns true if the value is null.

Arguments

NameTypeDescription
valueOBJECTParameter.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

notNull

notNull(value: V) → V NOT NULL

Asserts that the value is not null and returns it as NOT NULL.

Arguments

NameTypeDescription
valuevInput value expected to be not null.

Returns

TypeDescription
V NOT NULLSelected value.

toNullable

toNullable(value: V) → V

Casts a value to a nullable type (removes NOT NULL constraint).

Arguments

NameTypeDescription
valueVInput value.

Returns

TypeDescription
VSelected value.

Numeric comparisons and logic

Use these functions to perform operations based on numeric comparisons and logic.

between

between(value: FLOAT, min: FLOAT NOT NULL, max: FLOAT NOT NULL) → BOOL

Returns true if value is within the inclusive range [min, max].

Arguments

NameTypeDescription
valueFLOATValue to test.
minFLOAT NOT NULLLower bound (inclusive).
maxFLOAT NOT NULLUpper bound (inclusive).

Returns

TypeDescription
BOOLBoolean result.

greater

greater(a: NUMBER, b: NUMBER) → BOOL

Returns true if a is greater than b.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
BOOLBoolean result.

greaterOrEquals

greaterOrEquals(a: NUMBER, b: NUMBER) → BOOL

Returns true if a is greater than or equal to b.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
BOOLBoolean result.

if

if(expression: BOOL, v1: V, v2: V) → V

Conditional expression: returns v1 if expression is true, otherwise v2.

Arguments

NameTypeDescription
expressionBOOLCondition to evaluate.
v1VValue returned when condition is true.
v2VValue returned when condition is false.

Returns

TypeDescription
VSelected value.

less

less(a: NUMBER, b: NUMBER) → BOOL

Returns true if a is less than b.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
BOOLBoolean result.

lessOrEquals

lessOrEquals(a: NUMBER, b: NUMBER) → BOOL

Returns true if a is less than or equal to b.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
BOOLBoolean result.

Numeric math and statistics

Use these functions to perform operations based on the numeric math and statistics.

abs

abs(value: INT) → INT
abs(value: FLOAT) → FLOAT

Returns the absolute value.

Arguments

NameTypeDescription
valueINT | FLOATParameter.

Returns

TypeDescription
INT | FLOATNumeric result.

avg

avg(stream: V : NUMBER*) → FLOAT

Average of a stream of numbers.

Arguments

NameTypeDescription
streamV : NUMBER*Stream of numbers.

Returns

TypeDescription
FLOATAverage of the stream.

diffPct

diffPct(a: NUMBER, b: NUMBER) → FLOAT

Returns the percent difference between two numbers: 100 * abs((a - b) / b), with non-finite handling.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
FLOATNumeric result.

diffPctMax

diffPctMax(a: NUMBER, b: NUMBER) → FLOAT

Returns the percent difference normalized by max(abs(a), abs(b)): 100 * abs((a - b) / max(...)), with non-finite handling.

Arguments

NameTypeDescription
aNUMBERFirst numeric argument.
bNUMBERSecond numeric argument.

Returns

TypeDescription
FLOATNumeric result.

max

max(l: NUMBER, r: NUMBER) → FLOAT

Returns the larger of two numbers.

Arguments

NameTypeDescription
lNUMBERFirst numeric argument.
rNUMBERSecond numeric argument.

Returns

TypeDescription
FLOATNumeric result.

max

max(stream: V : COMPARABLE*) → V : COMPARABLE

Maximum of a stream of Comparable elements

Arguments

NameTypeDescription
streamV : COMPARABLE*Stream of comparable elements.

Returns

TypeDescription
V : COMPARABLEMaximum of the stream.

min

min(l: NUMBER, r: NUMBER) → FLOAT

Returns the smaller of two numbers.

Arguments

NameTypeDescription
lNUMBERFirst numeric argument.
rNUMBERSecond numeric argument.

Returns

TypeDescription
FLOATNumeric result.

min

min(stream: V : COMPARABLE*) → V : COMPARABLE

Minimum of a stream of comparable elements.

Arguments

NameTypeDescription
streamV : COMPARABLE*Stream of comparable elements.

Returns

TypeDescription
V : COMPARABLEMinimum of the stream.

modulo

modulo(a: FLOAT, b: FLOAT) → FLOAT
modulo(a: INT, b: INT) → INT

Returns the remainder of division (a % b).

Arguments

NameTypeDescription
aFLOAT | INTFirst numeric argument.
bFLOAT | INTSecond numeric argument.

Returns

TypeDescription
FLOAT | INTNumeric result.

moduloOrZero

moduloOrZero(a: FLOAT, b: FLOAT) → FLOAT
moduloOrZero(a: INT, b: INT) → INT

Returns a % b; if b is zero, returns 0 to avoid division by zero.

Arguments

NameTypeDescription
aFLOAT | INTFirst numeric argument.
bFLOAT | INTSecond numeric argument.

Returns

TypeDescription
FLOAT | INTNumeric result.

round

round(a: FLOAT) → INT

Rounds the floating-point value to the nearest integer.

Arguments

NameTypeDescription
aFLOATParameter.

Returns

TypeDescription
INTResult value.

stddevSamp

stddevSamp(stream: V : NUMBER*) → FLOAT

Sample standard deviation of a stream.

Arguments

NameTypeDescription
streamV : NUMBER*Stream.

Returns

TypeDescription
FLOATSample standard deviation.

sum

sum(value: INT*) → INT
sum(value: FLOAT*) → FLOAT

Returns the sum of all numbers in the stream.

Arguments

NameTypeDescription
valueFLOAT | INTInput numeric stream.

Returns

TypeDescription
FLOAT | INTNumeric result.

Stream aggregations

Use these functions to perform operations based on stream aggregations.

allValues

allValues(stream: V*) → V[]

List of non-null values of the stream.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
V[]List of non-null values of the stream.

anyValue

anyValue(stream: V*) → V

Any value from a stream.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
VAny value from a stream.

count

count(stream: V*) → INT

Number of elements in a stream.

Arguments

NameTypeDescription
streamVStream to count.

Returns

TypeDescription
INTNumber of elements in a stream.

count

count() → (VOID*) ->INT

Aggregates a stream and returns a derived value.

Returns

TypeDescription
(VOID*) ->INTResulting integer value.

distinct

distinct(stream: V*) → V[]

A copy of given stream without duplicates.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
V[]Stream without duplicates.

distinctCount

distinctCount(stream: V*) → INT

Amount of distinct elements in the stream.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
INTAmount of distinct elements in the stream.

firstValue

firstValue(stream: V*) → V

First value of a stream.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
VFirst value of a stream.

lastValue

lastValue(stream: V*) → V

Last value of a stream.

Arguments

NameTypeDescription
streamVStream.

Returns

TypeDescription
VLast value of a stream.

lastValues

lastValues(stream: V*, amount: INT NOT NULL) → V[]

Last amount elements of the stream.

Arguments

NameTypeDescription
streamVStream.
amountINT NOT NULLNumber of elements to keep.

Returns

TypeDescription
V[]list containing last amount values of the stream.

String operations

Use these functions to perform string operations.

endsWith

endsWith(s: STRING, suffix: STRING) → BOOL NOT NULL

Returns true if the string ends with the given suffix.

Arguments

NameTypeDescription
sSTRINGInput string.
suffixSTRINGSuffix to check.

Returns

TypeDescription
BOOL NOT NULLResult value.

equalsIgnoreCase

equalsIgnoreCase(s: STRING, p: STRING) → BOOL NOT NULL

Returns true if the two strings are equal ignoring case.

Arguments

NameTypeDescription
sSTRINGInput string.
pSTRINGString to compare with.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

matches

matches(s: STRING, pattern: STRING) → BOOL NOT NULL

Returns true if the string matches the given regular expression pattern.

Arguments

NameTypeDescription
sSTRINGInput string.
patternSTRINGRegular expression pattern.

Returns

TypeDescription
BOOL NOT NULLBoolean result.

startsWith

startsWith(s: STRING, prefix: STRING) → BOOL NOT NULL

Returns true if the string starts with the given prefix.

Arguments

NameTypeDescription
sSTRINGInput string.
prefixSTRINGPrefix to check.

Returns

TypeDescription
BOOL NOT NULLResult value.

substring

substring(s: V : STRING, offset: INT NOT NULL, len: INT NOT NULL) → V : STRING

Returns a substring starting at the given offset with the given length.

Arguments

NameTypeDescription
sV : STRINGInput string.
offsetINT NOT NULLZero-based start index.
lenINT NOT NULLNumber of characters to take.

Returns

TypeDescription
V : STRINGResulting string.

trim

trim(s: STRING) → STRING

Removes leading and trailing whitespace from a string.

Arguments

NameTypeDescription
sSTRINGInput string.

Returns

TypeDescription
STRINGResulting string.

Type casting

Use these functions to perform operations based on type casting.

BOOL

BOOL(obj: OBJECT) → BOOL

Casts the given object to BOOL.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
BOOLValue cast to BOOL.

DATE

DATE(obj: OBJECT) → DATE

Casts the given object to DATE.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
DATEValue cast to DATE.

DURATION

DURATION(obj: OBJECT) → DURATION

Casts the given object to DURATION.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
DURATIONValue cast to DURATION.

FLOAT

FLOAT(obj: OBJECT) → FLOAT

Casts the given object to FLOAT.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
FLOATValue cast to FLOAT.

INT

INT(obj: OBJECT) → INT

Casts the given object to INT.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
INTValue cast to INT.

NUMBER

NUMBER(obj: OBJECT) → NUMBER

Casts the given object to NUMBER.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
NUMBERValue cast to NUMBER.

STRING

STRING(obj: OBJECT) → STRING

Casts the given object to STRING.

Arguments

NameTypeDescription
objOBJECTValue to cast/check.

Returns

TypeDescription
STRINGValue cast to STRING.

Other

Use these functions to perform operations not covered in the categories above.

ifNotFinite

ifNotFinite(value: FLOAT, defValue: V : FLOAT) → V : FLOAT

Returns value if it is a finite number; otherwise returns defValue.

Arguments

NameTypeDescription
valueFLOATThe value to check for finiteness.
defValueV : FLOATThe value to return if value is not finite.

Returns

TypeDescription
V : FLOATThe original value if it is finite; otherwise defValue.