Built-in Functions

The following functions are available and can be used in expressions and unary-tests.

Note that some function/parameter names contain whitespaces. However, they can be invoked directly - without escaping the name.

Conversion Functions

Convert a value into a different type.

date()

date(birthday) 
// date("2018-04-29")

date(date and time("2012-12-25T11:00:00"))
// date("2012-12-25")

date(2012, 12, 25)
// date("2012-12-25")

time()

time(lunchTime) 
// time("12:00:00")

time(date and time("2012-12-25T11:00:00"))
// time("11:00:00")

time(23, 59, 0)
// time("23:59:00")

time(14, 30, 0, duration("PT1H"))
// time("15:30:00")

date and time()

date and time(date("2012-12-24"),time("T23:59:00")) 
// date and time("2012-12-24T23:59:00")

date and time(date and time("2012-12-25T11:00:00"),time("T23:59:00"))
// date and time("2012-12-25T23:59:00")

date and time(birthday) 
// date and time("2018-04-29T009:30:00")

duration()

duration(weekDays)
// duration("P5D")

duration(age)
// duration("P32Y")

years and months duration()

years and months duration(date("2011-12-22"), date("2013-08-24"))
// duration("P1Y8M")

number()

number("1500.5") 
// 1500.5

string()

string(1.1) 
// "1.1"

string(date("2012-12-25"))
// "2012-12-25"

Boolean Functions

not()

not(true)
// false

String Functions

substring()

substring("foobar",3) 
// "obar"

substring("foobar",3,3) 
// "oba"

string length()

string length("foo") 
// 3

upper case()

upper case("aBc4") 
// "ABC4"

lower case()

lower case("aBc4") 
// "abc4"

substring before()

substring before("foobar", "bar") 
// "foo"

substring after()

substring after("foobar", "ob") 
// "ar"

contains()

contains("foobar", "of") 
// false

starts with()

starts with("foobar", "fo") 
// true

ends with()

ends with("foobar", "r") 
// true

matches()

matches("foobar", "^fo*bar") 
// true

replace()

replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")
// "[1=ab][2=]cd"

replace("0123456789", "(\d{3})(\d{3})(\d{4})", "($1) $2-$3")
// "(012) 345-6789"

split()

split("John Doe", "\s" ) 
// ["John", "Doe"]

split("a;b;c;;", ";")
// ["a", "b", "c", "", ""]

List Functions

list contains()

list contains([1,2,3], 2) 
// true

count()

count([1,2,3]) 
// 3

min()

min([1,2,3]) 
// 1

min(1,2,3) 
// 1

max()

min([1,2,3]) 
// 3

min(1,2,3) 
// 3

sum()

min([1,2,3]) 
// 6

min(1,2,3) 
// 6

product()

product([2, 3, 4])
// 24

product(2, 3, 4)
// 24

mean()

Returns the arithmetic mean (i.e. average).

mean([1,2,3])
// 2

mean(1,2,3)
// 2

median()

Returns the median element of the list of numbers.

median(8, 2, 5, 3, 4)
// 4

median([6, 1, 2, 3]) 
// 2.5

stddev()

Returns the standard deviation.

stddev(2, 4, 7, 5)
// 2.0816659994661326

stddev([2, 4, 7, 5])
// 2.0816659994661326

mode()

Returns the mode of the list of numbers.

mode(6, 3, 9, 6, 6) 
// [6]

mode([6, 1, 9, 6, 1]) 
// [1, 6]

and() / all()

and([true,false])
// false

and(false,null,true)
// false

or() / any()

or([false,true])
// true

or(false,null,true)
// true

sublist()

sublist([1,2,3], 2)
// [2,3]

sublist([1,2,3], 1, 2)
// [1,2]

append()

append([1], 2, 3)
// [1,2,3]

concatenate()

concatenate([1,2],[3]) 
// [1,2,3]

concatenate([1],[2],[3])
// [1,2,3]

insert before()

insert before([1,3],1,2) 
// [1,2,3]

remove()

remove([1,2,3], 2) 
// [1,3]

reverse()

reverse([1,2,3]) 
// [3,2,1]

index of()

index of([1,2,3,2],2) 
// [2,4]

union()

union([1,2],[2,3])
// [1,2,3]

distinct values()

distinct values([1,2,3,2,1])
// [1,2,3]

flatten()

flatten([[1,2],[[3]], 4])
// [1,2,3,4]

sort()

sort(list: [3,1,4,5,2], precedes: function(x,y) x < y) 
// [1,2,3,4,5]

Numeric Functions

decimal()

decimal(1/3, 2)
// .33

decimal(1.5, 0) 
// 2

floor()

floor(1.5)
// 1

floor(-1.5)
// -2

ceiling()

ceiling(1.5)
// 2

floor(-1.5)
// -1

abs()

abs(10)
// 10

abs(-10)
// 10

modulo()

Returns the remainder of the division of dividend by divisor.

modulo(12, 5)
// 2

sqrt()

Returns the square root.

sqrt(16)
// 4

log()

Returns the natural logarithm (base e) of the number.

log(10)
// 2.302585092994046

exp()

Returns the Euler’s number e raised to the power of number .

exp(5)
// 148.4131591025766

odd()

odd(5)
// true

even()

odd(5)
// false

Context Functions

get value()

Returns the value of the context entry with the given key.

get value({foo: 123}, "foo") 
// 123

get entries()

Returns the entries of the context as list of key-value-pairs.

get entries({foo: 123})
// [{key: "foo", value: 123}]