Function library

abs(numeric)

This function calculates the absolute value of a numeric value.

param1 = -1.2
abs(#param1)
1.2

param1 = 5.47
abs(#param1)
5.47

capitalize(string)

Returns the string with the first letter in upper case, others lower case.

param1 = "abc DEF"
capitalize(#param1)
Abc def

collect(list_of_objects, fieldname)

Takes a field from all objects in a list and returns those field values as a list.

param1 = [{ "brand": "Huawei" }, { "model": "OnePlus 5 A5000" }, { "brand": "Google" }]
collect(#param1, "brand")
["Huawei", "", "Google"]

concatenation (string + string)

param1 = "a"
param2 = "b"
#param1 + #param2
"ab"

contains(literal, list)

Checks if an element in the list matches the literal.

param1 = [1, 2, 3, 4, 5]
contains(2, #param1)
true

param1 = ["hello", "world", "!"]
contains("world", #param1)
true

param1 = ["hello", "world", "!"]
contains("5555", #param1)
false

param1 = ["red", "green", "blue"]
contains("dark blue", #param1)
false

contains(string, list, boolean)

With the use of the optional boolean parameter true you can check whether an element in the list is part of the string.

param1 = ["red", "green", "blue"]
contains("dark blue", #param1, true)
true

convert_comma(input, divisor, lowerUnit, upperUnit)

This function selects one of the two units and formats input in it. It is equivalent to:

if #input < #divisor then
  str(#input) + " " + #lowerUnit
else
  format_number(#input / #divisor) + " " + #upperUnit
param1 = 5300
convert_comma(#param1, 1000, "m", "km")
"5,3 km"

param1 = 900
convert_comma(#param1, 1000, "m", "km")
"900 m"

param1 = 120
convert_comma(#param1, 60, "Minuten", "Stunden")
"2 Stunden"

convert_count(input, divisor, lowerUnit, upperUnit)

This function takes a numeric count and converts it to a written currency or date value. The difference to convert_comma is that it uses whole numbers and both units instead of a decimal value.

param1 = 145
convert_count(#param1, 60, "Minuten", "Stunden")
"2 Stunden 25 Minuten"

param1 = 45
convert_count(#param1, 60, "minutes", "hours")
"45 minutes"

param1 = 350
convert_count(#param1, 100, "Cent", "Euro")
"3 Euro 50 Cent"

param1 = 100
convert_count(#param1, 25, "", ",")
"4,"

The fourth argument is a , (comma).

convert_count(input, divisor, lowerUnit, upperUnit, conjunction)

Same as above, but with a custom conjunction.

param1 = 350
convert_count(#param1, 100, "Cent", "Euro", "and")
"3 Euro and 50 Cent"

count(list)

Returns the number of elements in a list.

param1 = [1, 2, 10, 12, 14]
count(#param1)
5

count_uniques(list)

Returns a list of objects which contain the following fields:

  • value - the name of the value
  • count - the occurrences of the value

Supported data types in the list:

  • bool
  • string
  • int
  • double

Values with other types will be ignored.

The list is ordered by item count, highest first.

param1 = ["cat", "dog", "cat"]
count_uniques(#param1)
[{"value": "cat", "count": 2}, {"value": "dog", "count": 1}]

cur_lang()

This method returns the current language in the current text generation process as an ISO 2-letter code.

cur_lang()
es

Whatever language is currently used (here: Spain).

currency(double)

This function converts a double to a currency string, depending on the current culture.

param1 = 2.1
currency(#param1)
"2.10"

param1 = 1000000
currency(#param1)
"1,000,000.00"

The provided examples use the locale en_US

date_add(date, number, type)

This method adds a value to a given date string (e.g "16.06.2016") or date object and returns a date object.

Supported time units:

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds
param1 = "16.05.1983"
date_add(#param1, 3, "years")
<date 1986-05-16 00:00:00>

date_convert(datetime, format[, timezone])

This method converts a datetime string (e.g. "6.4.2019 13:10") to a specific format and returns it as a string. The datetime parameter can also be a date object (year, month, day).

If a timezone is given, datetime is converted to it before formatting, assuming it was UTC if no information is given. The list of valid timezone names can be found here.

Names for months and weekdays depend on the selected language.

param1 = "16.05.1983"
date_convert(#param1, "yyyy-MM-dd")
"1983-05-16"

param1 = "Wednesday, June 5, 2019 2:55:09.324 PM"
date_convert(#param1, "yyyy-MM-dd HH:mm:ss.SSS")
"2019-06-05 14:55:09.324"

Example to convert seconds since the UNIX epoch 1.1.1970 to a date.

param1 = 1559739675
date_convert(#param1, "yyyy-MM-dd HH:mm:ss")
"2019-06-05 15:01:15"

Example converting a ISO-8601 datetime string to a different timezone:

dt = "2019-08-01T08:15:47+0200"
date_convert(#dt, "yyyy-MM-dd HH:mm:ss ZZ", "US/Pacific")
"2019-07-31 23:15:47 -07:00"

date_day_of_year(date)

This method returns the day of the year of a given date string or date object as a numeric. It is equivalent to int(date_convert(date, "DDD")).

param1 = "31.12.2010"
date_day_of_year(#param1)
365

param1 = "this_is_not_a_valid_date"
date_day_of_year(#param1)
0

date_difference(date, date)

This method returns the difference between two dates as an integer representing the absolute number of days. The expected input formats are a date string or a date object.

param1 = "16.05.1983"
param2 = "19.05.1983"
date_difference(#param1, #param2)
3

param1 = "19.05.1983"
param2 = "16.05.1983"
date_difference(#param1, #param2)
-3

date_format(date)

Guesses the format string of a date value. To format a date, see date_convert().

param1 = "16.05.1983"
date_format(#param1)
"dd.MM.yyyy"

This function is deprecated and only works in very specific cases. Do not use in new projects.

date_now()

Returns the current date (in Germany) as a string. See the second form below for more control.

date_now()
"13.06.2015"

date_now(format[, timezone])

Returns the current date and/or time in a specific format and timezone (defaults to "Europe/Berlin"). The list of valid timezone names can be found here.

date_now("yyyy-MM-dd")
"2015-06-13"

date_now("dd.MM.YYYY HH:mm:ss.SSSSZ")
"18.06.2019 16:43:23.2648+0000"

Example printing the current time for different timezones:

date_now("HH:mm")
date_now("HH:mm", "US/Pacific")
date_now("HH:mm", "Japan")
"08:33"
"23:33"
"15:34"

For political timezones, the daylight saving time of the respective country is applied:

date_now("Z")
"+0100" in winter, "+0200" in summer

filter(list)

Removes empty items (strings, lists, or objects) from a list.

param1 = ["",1,"a", {"examplekey":""},"",[],{}]
filter(#param1)
[1, "a", { "examplekey": "" }]

filter(list, object/lambda_expression)

Filters a list of objects for the elements that match a given filter object or lambda expression.

param1 = [{
			 "dummykey": "dummyvalue"
			},{
			 "Brand": "Xiaomi",
			 "Model": "Mi Mix",
			 "Price": "$482.99",
			 "Ram": "4 GB"
			},{
			 "Brand": "OnePlus",
			 "Model": "OnePlus 3T A3010",
			 "Price": "$489.98",
			 "Ram": "6 GB"
			},{
			 "Brand": "Huawei",
			 "Model": "Huawei Mate 9 Pro",
			 "Price": "$630.00",
			 "Ram": "6 GB"
			},{
			 "Brand": "Huawei",
			 "Model": "Huawei P10 Plus VKY-L29",
			 "Price": "$596.97",
			 "Ram": "6 GB"
			},{
			 "Brand": "Google",
			 "Model": "Google Pixel XL",
			 "Price": "$692.68",
			 "Ram": "4 GB"}]
filter(#param1, {"Brand": "Huawei"})
[{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "$630.00",
 "Ram": "6 GB"
},
{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "$596.97",
 "Ram": "6 GB"
}]

Pay attention to capital and small letters (case sensitive).


Input and output list same as above.

param1
filter(#param1, [listelement -> #listelement.Brand == "Huawei"])
[{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "$630.00",
 "Ram": "6 GB"
},
{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "$596.97",
 "Ram": "6 GB"
}]
Lambda Explanation:
[listelement -> #listelement.Brand == "Huawei"]
[ notation
listelement pick an element from a list
(variable name)
-> operator
#listelement.Brand access the value from a string-key value pair of the picked object
(name must match )
== compare operator
"Huawei" string
] notation

In this example, the variable list element of the Lambda expression contains a complete object of the list, which is used for comparison.


Input same as above.

param1
filter(#param1, [listelement, index, content -> #listelement.Ram == #content.Ram], {"Ram": "6 GB"})
[{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "$630.00",
 "Ram": "6 GB"
},
{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "$596.97",
 "Ram": "6 GB"
},{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "$489.98",
 "Ram": "6 GB"
}]
Lambda Explanation:
[listelement, index, content -> #listelement.Ram == #content.Ram]
[ notation
listelement pick an object from a list
(variable name)
index Variable to access the list index
(optional, when content parameter not set)
content Variable to access the additional content parameter of the filter method (here: data_ram)
(passed as third argument to the method)
-> operator
#listelement.Ram access the value of the key Ram of the picked object
(name must match )
== comparison operator
#content.Ram access the value of the key Ram from another content
(passed as a third argument to the method)
] notation

In this example, the variable listelement of the Lambda Expression takes an object from the list and compares the defined key with the defined key of the variable content, which pulls an external object into the Lambda Expression. If the values are identical, the object from the list is returned. This is done for each item in the list. Variable index must be set even if it is not used.

first(list)

Returns the first item of a list.

first(list, number)

Gets n elements from a list, starting with the first list element. A positive integer will return the first n elements of the list. A negative integer will return the last n elements of the list.

param1 = [ 1, 2, 3, 4, 5 ]
first(#param1, 3)
[1, 2, 3]

param1 = [ 1, 2, 3, 4, 5 ]
first(#param1, 5)
[1, 2, 3, 4, 5]

param1 = [ 1, 2, 3, 4, 5 ]
first(#param1, 6)
[ 1, 2, 3, 4, 5 ]

Output is the same as for 5.


param1 = [ 1, 2, 3, 4, 5 ]
first(#param1, -3)
[3, 4, 5]

This method call will return the last 3 elements of the list because a negative integer is used.

flatten(nested_list)

Removes layers from nested lists by inserting the values from the nested part into the first layer of the list.

Please note that this does nothing for lists of objects. For that see the map function.

list = ["a", ["b", "c", "d"], ["e", ["f", "g"]], [["h", ["i", "j", ["k", "l"]]]]]
flatten(#list)
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]

flatten(nested_list, max_depth)

Like flatten(nested_list), but only for a limited number of levels.

list = ["a", ["b", "c", "d"], ["e", ["f", "g"]], [["h", ["i", "j", ["k", "l"]]]]]
flatten(#list, 1)
flatten(#list, 2)
flatten(#list, 3)
flatten(#list, 4)
["a", "b", "c", "d", "e", ["f", "g"], ["h", ["i", "j", ["k", "l"]]]]
["a", "b", "c", "d", "e", "f", "g", "h", ["i", "j", ["k", "l"]]]
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ["k", "l"]]
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]

format_number(number, decimal_digits)

Return a number with an enforced number of decimal digits in the current locale.

param1 = 2
format_number(#param1, 2)
2.00

Output uses locale en-US.


Input same as above.

param1 = 2
format_number(#param1, 2)
2,00

Output uses locale de-DE.

get(table, key[, fallback])

Look up an entry in a lookup table or object. If nothing is found, it returns fallback if given, or key otherwise.

Equivalent to first(filter([#table[#key], #fallback])).

key = "NFC"
get(#smartphone_terms, #key)
"Near Field Communication"

The above example returns "NFC" if not in the lookup table, or no translation for the current language exists. To instead return nothing:

get(#smartphone_terms, #key, "")

group_digits(double)

This function converts any double to a formatted string, depending on the current culture.

param1 = 2.1
group_digits(#param1)
"2.1"

param1 = 1000000
group_digits(#param1)
"1,000,000"

The provided examples use the locale en-US, correct delimiters will be introduced depending on language.

has_voc(phrase)

Returns True if phrase is a) a triggered phrase node, or b) a lookup table value, and defines at least one phrase for the current language.

table = <a lookup table>
has_voc(#table.key)
true

histogram_data(data_field_name)

Returns a JSON object with the count, types and min/max/average values corresponding to the given data_field_name, which is searched for in the current collection histogram.

Example collection:

[{
  "Prozessorleistung_GHz": 2.7,
  "Hersteller": "Samsung",
  "Betriebssystem": "Android",
  "Kategorie": "Smartphone",
  "Prozessorleistung_Kerne": "Quad-Core",
  "Abmessungen_HxBxT_cm": "15,3 x 7,9 x 0,9",
  "Displaygroesse_Zoll": 3,
  "Name": "Galaxy Note 4",
  "Farbe": "schwarz",
  "Speicher_GB": 16,
  "Gewicht_g": 176,
  "Features": "LTE|W-LAN|Bluetooth",
  "Kamera_megapixel": 5
},
{
  "Prozessorleistung_GHz": 2.7,
  "Hersteller": "Apple",
  "Betriebssystem": "iOS",
  "Kategorie": "Smartphone",
  "Prozessorleistung_Kerne": "Quad-Core",
  "Abmessungen_HxBxT_cm": "15,3 x 7,9 x 0,9",
  "Displaygroesse_Zoll": 4.7,
  "Name": "iPhone 7",
  "Farbe": "gold",
  "Speicher_GB": 128,
  "Gewicht_g": 150,
  "Features": "LTE|W-LAN|Bluetooth",
  "Kamera_megapixel": 2
},
{
  "Abmessungen_HxBxT_cm": "15,3 x 7,9 x 0,9",
  "Gewicht_g": "",
  "Speicher_GB": 16,
  "Farbe": "schwarz",
  "Kategorie": "Smartphone",
  "Prozessorleistung_GHz": 2.7,
  "Hersteller": "Samsung",
  "Name": "Galaxy S7",
  "Betriebssystem": "Android",
  "Features": "LTE|W-LAN|NFC",
  "Displaygroesse_Zoll": 5,
  "Prozessorleistung_Kerne": "Quad-Core",
  "Kamera_megapixel": 12
}
histogram_data("Displaygroesse_Zoll")
{
	"count": 3,
	"types": {
		"number": {
			"avg": 4.233333333333333,
			"max": 5,
			"min": 3,
			"sum": 12.7,
			"count": 3,
			"percentiles": [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]
		}
	},
	"values": [{
		"type": "number",
		"count": 1,
		"value": "3"
	},
	{
		"type": "number",
		"count": 1,
		"value": "5"
	},
	{
		"type": "number",
		"count": 1,
		"value": "4.7"
	}],
	"avg": 4.233333333333333,
	"max": 5,
	"min": 3,
	"sum": 12.7,
	"percentiles": [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]
}

This is the output format for numeric data fields.


Same example collection as above.

histogram_data("Displaygroesse_Zoll")
{
	"count": 3,
	"types": {
		"string": {
			"count": 3
		}
	},
	"values": [{
		"type": "string",
		"count": 1,
		"value": "Apple"
	},
	{
		"type": "string",
		"count": 2,
		"value": "Samsung"
	}]
}

This is the output format for string data fields.

in_range(number, lower_bound, upper_bound)

Checks if a numeric value lies inside a certain interval. The method returns true if lower_bound <= number <= upper_bound and false otherwise.

param1 = 6
in_range(#param1, 5, 10)
true

param1 = 12
in_range(#param1, 5, 10)
false

intersection(list, list)

Returns a list of the elements which are present in both list inputs.

list1 = [1, 2, 3]
list2 = [1, 2, 4]
intersection(#list1, #list2)
[1, 2]

is_date(string)

Checks if a string value can be parsed as a date.

param1 = "16.05.1983"
is_date(#param1)
true

param1 = "abcDEF"
is_date(#param1)
false

This function only states that calling date(string) will not cause an error. It does not mean the date will be interpreted correctly.

join(list[, delimiter])

Return a single string by concatenating all the items of a list of strings. If given, add delimiter between each item.

param1 = [1, 2, 3, 4, 5]
join(#param1)
"12345"

param1 = [1, 2, 3, 4, 5]
join(#param1, "a-")
"1a-2a-3a-4a-5"

len(string)

Returns the length of a string (or the string representation of a value).

param1 = "basics"
len(#param1)
6

param1 = 1234567890
len(#param1)
10

list_pos(list, search_string)

This method finds the position of a data value in a list.

param1 = ["hello","world"]
list_pos(#param1, "hello")
0

First element in the list has the position 0 (index 0).


param1 = ["hello","world"]
list_pos(#param1, "notAWord")
-1

String notAWord was not found in the list.

lower(string)

This method converts a string to its lowercase form.

param1 = "STRING"
lower(#param1)
string

map(list, lambda_expression)

Applies a method to all elements of a list and returns a list of objects with the result of the applied lambda expression.

param1 = [1, 2, 3]
map(#param1, [element -> numeric(#element) + 2])
[3, 4, 5]
Lambda Explanation:
[element -> numeric(#element) + 2]
[ notation
element pick an element from a list
(variable name)
-> operator
numeric() ATML3-Method
#element access value from the
picked element
(name must match )
+ 2 math: add 2
] notation

param1 = [
  {"Brand": "Xiaomi", "Model": "Mi Mix"},
  {"Brand": "OnePlus", "Model": "OnePlus 3T A3010"},
  {"Brand": "Huwawei", "Model": "Huawei Mate 9 Pro"}
]
map(#param1, [entry -> #entry.Brand])
[ "Xiaomi", "OnePlus", "Huwawei"]
Lambda Explanation:
[entry -> #entry.Brand]
[ notation
entry pick an object from a list
(variable name)
-> operator
numeric() ATML3-Method
#entry.Brand access the value from a string-key value pair of the picked object
(name must match )
] notation

map(list, lambda_expression, context)

Applies a method to all elements of a list and returns a list of objects with the result of the applied lambda expression.

param1 = [
  {"Brand": "Xiaomi", "Model": "Mi Mix"},
  {"Brand": "OnePlus", "Model": "OnePlus 3T A3010"},
  {"Brand": "Huwawei", "Model": "Huawei Mate 9 Pro"}
]
map(#param1, [entry, index, content -> #entry.Brand + " (" + str(#index) + ") [" + str(#content) + "]"], "Content")
[ "Xiaomi (0) [Content]", "OnePlus (1) [Content]", "Huwawei (2) [Content]"]
Lambda Explanation:
[entry, index, content -> #entry.Brand + " (" + #index + ") [" + #content + "]"]
[ notation
entry pick an object from a list
(variable name)
index Variable to access the list index
(optional)
content Variable to access the additional content parameter
(passed as third argument to the method)
-> operator
#entry.Brand access the value from a string-key value pair of the picked object by key name
(name must match )
+ operator
(string concatenation)
" (" string
(white space and a bracket)
#index access the list index
") [" string
(bracket, white space and a bracket)
+ operator
(string concatenation)
#content access the value of the additional parameter
(passed as a third argument to the method)
+ operator
(string concatenation)
"]" string
(a bracket)
] notation

The function map has 3 parameters. In this example we passed a string Content as an argument to this third parameter.


param1 = ["Brand", "Model"]
param2 = ["Xiaomi", "Mi Mix"]
map(#param1, [entry, index, content -> #entry + " (" + #content[#index] + ")"], #param2)
["Brand (Xiaomi)", "Model (Mi Mix)"]
Lambda Explanation:
[entry, index, content -> #entry + " (" + #content[#index] + ")"]
[ notation
entry pick an object from a list
(variable name)
index Variable to access the list index
(optional)
content Variable to access the additional content parameter
(passed as third argument to the method)
-> operator
#entry access the value the picked element
(name must match )
+ operator
(string concatenation)
" (" string
(white space and a bracket)
#content access the value of the additional parameter
(passed as a third argument to the method)
[ list access notation
(passed as a third argument to the method)
#index access the list index
] list access notation
(passed as a third argument to the method)
+ operator
(string concatenation)
")" string
(bracket)
] notation

In the expression #content[#index] the #index is taken from the picked element, which is set with the variable entry. The passed argument Content is a list that can be accessed directly with #context[] notation. In this example we used the index of the first list (param1) to access the value at the same index of the second list (param2).

max(list)

Returns the maximum value from a list of numerics.

param1 = [1, 2, 3, 6, 4, 5]
max(#param1)
6

min(list)

Returns the minimum value from a list of numerics.

param1 = [1, 2, 3.2, 6, 4, 5]
min(#param1)
1

month_no(string)

Returns the month name in a numeric representation.

This function only supports the German and English notation of months.

Use int(date_convert(date(#month_name, "MMMM"), "M")) for better locale support.

month_name = "Januar"
month_no(#month_name)
1

month_name = "February"
month_no(#month_name)
2

neg_filter(list, object/lambda_expression)

This method filters a list of objects for the elements that match a given filter object or lambda expression. The elements that match the filter condition are removed.

AND concatenation of the search parameters

param1 = [
{
 "dummykey": "dummyvalue"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
},
{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "$489.98",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "$630.00",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "$596.97",
 "Ram": "6 GB"
},{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "$692.68",
 "Ram": "4 GB"
}]
neg_filter( #param1, {"Brand": "Huawei", "Ram":"6 GB"})
[{
 "dummykey": "dummyvalue"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
},
{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "$489.98",
 "Ram": "6 GB"
},{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "$692.68",
 "Ram": "4 GB"
}]

Returns a list that includes the objects from the given input list that do not contain entries having Brand=Huawei AND Ram=4 GB. In this case, the objects with list indices 3 and 4 of the original list are removed.


Input same as above.

param1
neg_filter(#param1, {"Ram":"6 GB"})
[{
 "dummykey": "dummyvalue"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
},
{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "$692.68",
 "Ram": "4 GB"
}]

Returns a list with objects that do not have Ram=6 GB. In this case, the objects with list indices 2, 3 and 4 of the original list are removed.


Input same as above.

param1
neg_filter( #param1, [listelement -> #listelement.Ram == "6 GB" ])
[{
 "dummykey": "dummyvalue"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
},
{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "$692.68",
 "Ram": "4 GB"
}]

Does the same thing as the last example but uses a lambda expression to match the object. In this example, the entry variable of the lambda expression contains the object to be matched.

Explanation of the lambda expression:
[listelement -> #listelement.Ram == "6 GB" ]
[ notation
listelement pick an element from a list
(variable name)
-> operator
#listelement.Ram access the value from a string-key value pair of the picked object
(name must match )
== compare operator
"6 GB" string
] notation

Input same as above.

param1
neg_filter(#param1, [listelement -> #listelement.Brand in ["Huawei", "Google"]])
[{
 "dummykey": "dummyvalue"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
},
{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "$489.98",
 "Ram": "6 GB"
}]

Returns a list with entries that do not have Brand=Huawei OR_ Google, in our example entry 3,4 and 5 of the original list. In this example, the entry variable of the lambda expression contains the object to be matched.

Explanation of the lambda expression:
[listelement -> #listelement.Brand == "Huawei" or #listelement.Brand == "Google" ]
[ notation
listelement pick an element from a list
(variable name)
-> operator
#listelement.Brand access the value from a string-key value pair of the picked object
(name must match )
== compare operator
"Huawei" string
or logical operator
(if one or the other or both strings can be matched)
#listelement.Brand access the value from a string-key value pair of the picked object
(name must match )
== compare operator
"Google" string
] notation

param1 = [{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "$489.98",
 "Ram": "6 GB"
},
{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
}]
neg_filter(#param1, [entry, index, context -> #entry.Brand == #context.examplelist[#index] ], {"examplelist":["OnePlus","Google"]})
[{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "$482.99",
 "Ram": "4 GB"
}]

This is the maximum filled lambda expression.

Explanation of the lambda expression:
[entry, index, context -> #entry.Brand == #context.examplelist[#index] ]
[ notation
entry pick an object from a list
(variable name)
index Variable to access the list index
(optional)
content Variable to access the additional content parameter
(passed as third argument to the method)
-> operator
#entry.Brand access the value from a string-key value pair of the picked object by key name
(name must match)
== compare operator<
#context access the additional parameter
(passed as a third argument to the method)
. notation
(access the value of the following key from a string-key value pair of the an object
examplelist key name
(in the #context object)
[#index] access the list index
(access list elements with the same index)
] notation

pick_object(list_of_objects, key, value)

Returns the first object in list_of_objects which has key == value.

This is equivalent to first(filter(list_of_objects, {key: value})) but slightly faster.

param1 = {
  "object": {
    "list": [{
        "brand": "Huawei",
        "model": "Huawei Mate 9 Pro"

      },
      {
        "brand": "Huawei",
        "model": "Huawei P10 Plus VKY-L29"

      },
      {
        "exampleFieldName": "exampleValue"

      }

    ]
  }
}
pick_object(#param1.object.list, "model", "Huawei P10 Plus VKY-L29")
{
  "brand": "Huawei",
  "model": "Huawei P10 Plus VKY-L29"
}

Input same as above.

param1 =
pick_object(#param1.object.list, "exampleFieldName", "exampleValue")
{
  "exampleFieldName": "exampleValue"
}

random_el(list, number)

This method returns random elements from a list.

param1 = [1,2,3,4,5]
random_el(#param1, 3)
[3, 5, 2]

param1 = [1,2,3,4,5]
random_el(#param1, 5)
[5, 3, 1, 2, 4]

range(list, index, count)

Returns a slice of a list.

  • list - a list
  • index - the zero-based index at which the range starts
  • count - the number of elements in the range (for right-to-left range, use negative integers)

If index or count reach outside the list, it is silently ignored.

list = ["OnePlus", "Huawei", "Google", "Xiaomi", "Apple"]
range(#list, 4, 1)
range(#list, 5, 2)
range(#list, 3, 2)
range(#list, 3, 5)
["Apple"]
[]
["Xiaomi", "Apple"]
["Xiaomi", "Apple"]

list = ["OnePlus", "Huawei", "Google", "Xiaomi", "Apple"]
range(#list, -1, 2)
range(#list, 2, -2)
range(#list, 10, -1)
["OnePlus"]
["Huawei", "Google"]
[]

re_group(pattern, string[, "i"])

Finds the left-most match of pattern in string, then returns the first group (=expression in brackets) within that match. If pattern is not found, returns the empty string.

Optionally, it is also possible to match case insensitive ("i").

You can only extract one group.

param1 = "String1String2String3"
re_group("String1(.*)String3", #param1)
"String2"

param1 = "STRING1STRING2STRING3"
re_group("^.*(String2).*$", #param1, "i")
"STRING2"

re_find(list, pattern, direction, position)

This method searches for a regex pattern in a list of string elements and returns the string if there is a match. Otherwise an empty string is returned.

  • list - the input list
  • pattern - a regular expression pattern
  • direction - the direction of the search Valid values: l and r
  • position - position in the list, where the search starts Valid values: any integer >= 0
param1 = [1, 2, 30]
re_find(#param1, "3.*", "l", 0)
30

param1 = [10, 2, 3]
re_find(#param1, "1.*", "r", 0)
10

param1 = [1, 2, 3]
re_find(#param1, "4", "l", 0)
""

re_get(list, pattern, direction, position)

Returns a specific item from a list, but only if it matches the RegEx pattern.

  • list - the input list
  • pattern - a regular expression pattern
  • direction - "l" so position counts from the start of the list, "r" from the end
  • position - index into the list (0 to count(list) - 1)

The return value is always a string, even if it wasn't in the list.

number_list = [1, 2, 3]
re_get(#number_list, ".*", "l", 0)
re_get(#number_list, ".*", "r", 0)
re_get(#number_list, "4", "l", 0)
"1"
"3"
""

list = ["foobarbaz"]
re_get(#list, "foo", "l", 0)
re_get(#list, "bar", "l", 0)
re_get(#list, "baz", "l", 0)
"foobarbaz"

re_keep(list, pattern)

Returns the list of all elements in list which match pattern.

Equivalent to

filter(flatten(#list), [item -> re_search(#pattern, #item)])
  • list - the input list
  • pattern - a regular expression pattern
param1 = ["xyz1", "abc", "xyz2"]
re_keep(#param1, "xyz.")
["xyz1", "xyz2"]

re_keep(list, pattern, direction, position)

This method searches for a regex pattern in a list and returns a list of all matched elements. Optionally, a starting position and a search direction can be given.

  • list - the input list
  • pattern - a regular expression pattern
  • direction - the direction of the search Valid values: l and r
  • position - position in the list, where the search starts Valid values: any integer >= 0 parameter is optional
param1 = ["xyz1", "abc", "xyz2"]
re_keep( #param1, "xyz.", "l", 1)
["xyz1"]

param1 = ["xyz1", "abc", "xyz2"]
re_keep(#param1, "xyz.", "r", 1)
["xyz2"]

re_match(pattern, string[, "i"])

Tests whether a string starts with a defined pattern. Use re_search() to allow matches anywhere in the string.

Optionally, it is also possible to match case insensitive ("i").

param1 = "String1String2"
re_match("String\d", #param1)
re_match("String2", #param1)
true
false

param1 = "STRING1STRING2"
re_match("String\d", #param1, "i")
true

re_remove(list, pattern)

Returns the list of all elements in list which do not match pattern.

Equivalent to

filter(flatten(#list), [item -> not re_search(#pattern, #item)])
  • list - the input list
  • pattern - a regular expression pattern
param1 = ["xyz1", "abc", "xyz2"]
re_remove(#param1, "abc")
["xyz1", "xyz2"]

re_remove(list, pattern, direction, position)

This method searches for a regex pattern in a list and returns a list of all elements that do not contain matched elements. Optionally, a starting position and a search direction can be given.

  • list - the input list
  • pattern - a regular expression pattern
  • direction - the direction of the search Valid values: l and r
  • position - position in the list, where the search starts Valid values: any integer >= 0 parameter is optional
param1 = ["xyz1", "abc", "xyz2"]
re_remove(#param1, "abc", "l", 1)
["xyz1", "xyz2"]

param1 = ["xyz1", "abc", "xyz2"]
re_remove(#param1, "xyz.", "r", 1)
["xyz1", "abc"]

re_replace(string, old, new)

Returns a new string in which all occurrences conforming to the RegEx pattern old in string have been replaced by new.

param1 = "old Old old Old"
re_replace(#param1, "(o|O)ld", "new")
"new new new new"

re_search(pattern, string[, "i"])

Tests whether a string matches a pattern. See re_match() to only allow matches at the start of string (or start pattern with ^).

Optionally, it is also possible to match case insensitive ("i").

param1 = "String1String2"
re_search("String\d", #param1)
re_search("String2", #param1)
true
true

param1 = "STRING1STRING2"
re_search("String\d", #param1, "i"))
true

replace(string, old, new)

This method replaces all occurrences of a substring with another.

param1 = "old old old old"
replace(#param1, "old", "new")
"new new new new"

replace(string, old, new, max)

This method replaces all occurrences of a substring with a new stated substring.

Optional parameter max sets the number of times of replacements.

param1 = "old old old old"
replace(#param1, "old", "new", 2)
"new new old old"

replace_last(string, old, new)

Returns a new string in which the last occurrences of old in string have been replaced with new.

param1 = "1, 2, 3, 4"
replace_last(#param1, ",", " and")
"1, 2, 3 and 4"

reverse(list)

Reverses the order of elements in a list.

list = [1, 2, 3, 4, 5]
reverse(#list)
[5, 4, 3, 2, 1]

rnd_dbl()

Returns a random number between 0 and 1.

rnd_dbl()
0.599179536848878

rnd_dbl(lower_limit, upper_limit)

This function returns a random number in the interval limited by lower_limit and upper_limit.

lower = 0.0
upper = 10.0
rnd_dbl(#lower, #upper)
7.73589949018131

rnd_int(lower_limit, upper_limit)

This function returns a random integer in the interval limited by lower_limit and upper_limit (inclusive).

param1 = 0
param2 = 10
rnd_int(#param1, #param2)
3

round(double)

This method rounds a numeric value. There's an optional parameter to set the decimals to round to.

The behavior of round() for doubles can be surprising due to the inexact representation of decimal fractions in the floating-point standard.

param1 = 0.6
round(#param1)
1

round(double, decimals)

This method rounds a numeric value. The optional parameter decimals specifies the number of decimal places to be rounded to.

param1 = 0.144743575
round(#param1, 2)
0.14

sort(list)

Sorts a list numerically or alphabetically (lowest to highest or A to Z).

param1 = [4, 5, 3, 2, 1]
sort(#param1)
[1, 2, 3, 4, 5]

sort(list, fieldname/lambda_expression)

Sorts a list of objects by a given field, or by a custom key from a lambda expression.

param1 = [{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "482.99",
 "Ram": "4 GB"
},
{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "489.98",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "630.00",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "596.97",
 "Ram": "6 GB"
},{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "692.68",
 "Ram": "4 GB"
}]
sort(#param1, "Price")
[{
  "Brand": "Xiaomi",
  "Model": "Mi Mix",
  "Price": "482.99",
  "Ram": "4 GB"
},
{
  "Brand": "OnePlus",
  "Model": "OnePlus 3T A3010",
  "Price": "489.98",
  "Ram": "6 GB"
},
{
  "Brand": "Huawei",
  "Model": "Huawei P10 Plus VKY-L29",
  "Price": "596.97",
  "Ram": "6 GB"
},
{
  "Brand": "Huawei",
  "Model": "Huawei Mate 9 Pro",
  "Price": "630.00",
  "Ram": "6 GB"
},
{
  "Brand": "Google",
  "Model": "Google Pixel XL",
  "Price": "692.68",
  "Ram": "4 GB"
}
]

Returns a sorted list with original elements sorted by the "Price" key in them (compare Huawei entries).


Example list of objects param1:


param1 = [{
 "Brand": "Xiaomi",
 "Model": "Mi Mix",
 "Price": "482.99",
 "Ram": "4 GB"
},
{
 "Brand": "OnePlus",
 "Model": "OnePlus 3T A3010",
 "Price": "489.98",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei Mate 9 Pro",
 "Price": "630.00",
 "Ram": "6 GB"
},{
 "Brand": "Huawei",
 "Model": "Huawei P10 Plus VKY-L29",
 "Price": "596.97",
 "Ram": "6 GB"
},{
 "Brand": "Google",
 "Model": "Google Pixel XL",
 "Price": "692.68",
 "Ram": "4 GB"
}]
sort(#param1, [item -> int(#item.Price)])
[{
  "Brand": "Xiaomi",
  "Model": "Mi Mix",
  "Price": "482.99",
  "Ram": "4 GB"
},
{
  "Brand": "OnePlus",
  "Model": "OnePlus 3T A3010",
  "Price": "489.98",
  "Ram": "6 GB"
},
{
  "Brand": "Huawei",
  "Model": "Huawei P10 Plus VKY-L29",
  "Price": "596.97",
  "Ram": "6 GB"
},
{
  "Brand": "Huawei",
  "Model": "Huawei Mate 9 Pro",
  "Price": "630.00",
  "Ram": "6 GB"
},
{
  "Brand": "Google",
  "Model": "Google Pixel XL",
  "Price": "692.68",
  "Ram": "4 GB"
}]

For each element, the field Price is interpreted as integer (i.e. [482, 489, 630, 596, 692]), then the list is sorted according to that.

When testing, you can replace sort with map to see what your key function is doing.

split(string[, delimiter])

Splits a string at every occurrence of delimiter, returning a list. If omitted, delimiter defaults to " " (whitespace).

If delimiter is not found, this function still returns a list, with string as the only item. If delimiter occurs multiple times in a row, you'll get empty elements in between.

param1 = "string1 string2 string3"
split(#param1)
["string1", "string2", "string3"]

param1 = "string1, string2, string3"
split(#param1, ", ")
["string1", "string2", "string3"]

sqrt(number)

Returns the square root of number.

sqrt(2)
1.414213562373

substring(string, index, length)

This method extracts a substring from a string with a starting given index and length.

param1 = "Hello world"
substring(#param1, 0, 1)
"H"

The substring from index 0 with a length of 1 character.


param1 = "Hello world"
substring(#param1, 5, 3)
"wor"

The substring from index 5 (the w) with a length of 3 characters.


param1 = "Hello world"
substring(#param1, 5)
"world"

The substring from index 5 to the end of the string.

sum(list)

Sums numeric elements in a list. It does not work with non-numeric elements.

param1 = [1, 2, 3]
sum(#param1)
6

traverse_json_path(object, path)

This function allows the navigation through complex JSON structures and the search in lists and sublists with a search mask.

path may consist of the following components:

  • .key: A key in an object. Contrary to the normal form available with parameters, this may contain whitespace and any character except ., [, or ].
  • [i]: An element of a list, by index.
  • [key=values;otherKey=values]: Finds the first element of the list which
    • is an object
    • has all of the specified keys
    • each key has one of the |-separated values (exact match).
object = {
  "data": [{
    "type": "a",
    "color": "red",
    "price": 345
  }, {
    "type": "b",
    "color": "red",
    "price": 239
  }, {
    "type": "b",
    "color": "blue",
    "price": 499
  }]
}
traverse_json_path(#object, "data[0].price")
traverse_json_path(#object, "data[type=b].price")
traverse_json_path(#object, "data[type=b;color=blue|green].price")
345
239
499

trim(string)

This method cuts away trailing and preceding whitespaces from a string.

param1 = "hello world"
trim(#param1)
"hello world"

Nothing to trim


param1 = " hello world"
trim(#param1)
"hello world"

Stripped whitespace from the beginning


Example data param1:

param1 = "hello world "
trim(#param1)
"hello world"

stripped whitespace from the end


param1 = " hello world "
trim(#param1)
"hello world"

Stripped whitespace from the beginning and the end

unique(list)

Finds the unique elements of a list.

param1 = [1, 2, 3, 1, 2]
unique(#param1)
[1, 2, 3]

upper(string)

Converts a string to uppercase.

param1 = "string"
upper(#param1)
"STRING"

weekday_int(days)

This method takes a numeric n between 1 and 7. It returns a numeric representation of the weekday of today + n days. The returned numeric is to be interpreted as follows:

Weekday Numeric
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
Sunday 7
param1 = 1
weekday_int(#param1)
2

In this example, the function weekday_int returns the integer 2 (Tuesday), because today is a Monday.


param1 = 5
weekday_int(#param1)
6

Output may differ. In this example the method returns the integer 6 (Saturday), because today is a Monday.

weekday_no(day)

This method can be used to convert a weekday into a numerical representation.

This method only supports the German and English notation of weekdays.

param1 = "Tuesday"
weekday_no(#param1)
2

Tuesday is the second day in a week.


param1 = "Monday"
weekday_no(#param1)
1

Monday is the first day of the week.