# # Function library

## #`abs(numeric)`

This function calculates the absolute value of a numeric value.

``````number = -1.2
``````
``````abs(#number)
``````
``````1.2
``````
``````number = 5.47
``````
``````abs(#number)
``````
``````5.47
``````

## #`all(list[, lambda_expression])`

Return true if all items of `list` fulfill the condition. If the list is empty, also returns true.

If `lambda_expression` is omitted, tests for empty items, exactly as filter().

TIP

This is equivalent to `count(filter(items, condition)) == count(items)`, but easier to read. It's also faster because it stops as soon as the first item fails `condition`.

``````all([1, 2, 3, 4, 5], [x -> #x > 0])
all([1, 2, 3, 4, 5], [x -> #x < 5])
all(["a", "b", "c"], [x -> #x == "c"])
``````
``````true   # All items are greater than zero
false  # The last item (5) is not smaller than 5
false  # Only one item equals "c"
``````

Usage with default condition:

``````all([])
all([""])
all(["a"])
``````
``````true   # No items
false  # One empty item
true   # One non-empty item
``````

## #`any(list[, lambda_expression])`

Return true if at least one item of `list` fulfills the condition. If the list is empty, returns false.

If `lambda_expression` is omitted, tests for non-empty items, exactly as filter().

TIP

This is equivalent to `count(filter(items, condition)) > 0`, but easier to read. It's also faster because it stops as soon as the first item fulfills `condition`.

``````any([1, 2, 3, 4, 5], [x -> #x > 0])
any([1, 2, 3, 4, 5], [x -> #x < 5])
any(["a", "b", "c"], [x -> #x == "c"])
``````
``````true   # All items are greater than zero
true   # Four of five items are smaller than five
true   # One item equals "c"
``````

Usage with default condition:

``````any([])
any([""])
any(["a", ""])
``````
``````false  # No items
false  # One empty item
true   # One non-empty item
``````

## #`capitalize(string)`

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

``````some_text = "abc DEF"
``````
``````capitalize(#some_text)
``````
``````Abc def
``````

## #`collect(list_of_objects, fieldname)`

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

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

## #`concatenation (string + string)`

``````string1 = "a"
string2 = "b"
``````
``````#string1 + #string2
``````
``````"ab"
``````

## #`contains(value, list)`

Checks if an element in the list matches the value.

``````list_of_numbers = [1, 2, 3, 4, 5]
``````
``````contains(2, #list_of_numbers)
``````
``````true
``````
``````list = ["hello", "world", "!"]
``````
``````contains("world", #list)
``````
``````true
``````
``````list = ["hello", "world", "!"]
``````
``````contains("5555", #list)
``````
``````false
``````
``````colors = ["red", "green", "blue"]
``````
``````contains("dark blue", #colors)
``````
``````false
``````

## #`contains(string, list, substring)`

When setting the optional `substring` parameter to `true`, a collection element may just partially match `value`, and also differ in case.

``````colors = ["Red", "Green", "Blue"]
``````
``````contains("dArK bLuE", #colors, true)
``````
``````true
``````

It does not test if `string` is part of a list item:

``````colors = ["red", "green", "dark blue"]
``````
``````contains("blue", #colors, true)
``````
``````false
``````

If you need that behavior, use any():

``````any(#colors, [item -> "blue" in #item])  # 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
``````
``````distance = 5300
``````
``````convert_comma(#distance, 1000, "m", "km")
``````
``````"5,3 km"
``````
``````distance = 900
``````
``````convert_comma(#distance, 1000, "m", "km")
``````
``````"900 m"
``````
``````duration = 120
``````
``````convert_comma(#duration, 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.

``````duration = 145
``````
``````convert_count(#duration, 60, "Minuten", "Stunden")
``````
``````"2 Stunden 25 Minuten"
``````
``````duration = 45
``````
``````convert_count(#duration, 60, "minutes", "hours")
``````
``````"45 minutes"
``````
``````amount = 350
``````
``````convert_count(#amount, 100, "Cent", "Euro")
``````
``````"3 Euro 50 Cent"
``````
``````amount = 100
``````
``````convert_count(#amount, 25, "", ",")
``````
``````"4,"
``````

WARNING

The fourth argument is a , (comma).

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

Same as above, but with a custom conjunction.

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

## #`count(list)`

Returns the number of elements in a list.

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

## #`count_uniques(list)`

Count duplicate elements of list. Returns a list of objects which contain the following fields:

• value - the list element
• count - number of occurrences in list (1 if element is unique)

The list elements must be strings or numbers. Nested lists are supported for convenience, and will be treated as a single flat list. The result is in the same order as the input, i.e. sorted by the element's first occurrence.

TIP

This is the same as unique(), except for including the number of occurrences.

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

A more complex example, with nested lists:

``````list1 = [1, 2, 2]
list2 = [14, 10, 12, 10]
``````
``````count_uniques([#list1, #list2, 2])
``````
``````[{"value": 1, "count": 1}, {"value": 2, "count": 3}, {"value": 14, "count": 1},
{"value": 10, "count": 2}, {"value": 12, "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
``````

WARNING

Whatever language is currently used (here: Spain).

## #`currency(double)`

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

``````amount = 2.1
``````
``````currency(#amount)
``````
``````"2.10"
``````
``````amount = 1000000
``````
``````currency(#amount)
``````
``````"1,000,000.00"
``````

WARNING

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`
``````date_string = "16.05.1983"
``````
``````date_add(#date_string, 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 (opens new window).

WARNING

Names for months and weekdays depend on the selected language.

``````date_string = "16.05.1983"
``````
``````date_convert(#date_string, "yyyy-MM-dd")
``````
``````"1983-05-16"
``````
``````date_string = "Wednesday, June 5, 2019 2:55:09.324 PM"
``````
``````date_convert(#date_string, "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.

``````timestamp = 1559739675
``````
``````date_convert(#timestamp, "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"))`.

``````date_string = "31.12.2010"
``````
``````date_day_of_year(#date_string)
``````
``````365
``````
``````date_string = "this_is_not_a_valid_date"
``````
``````date_day_of_year(#date_string)
``````
``````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.

``````date1 = "16.05.1983"
date2 = "19.05.1983"
``````
``````date_difference(#date1, #date2)
``````
``````3
``````

If the first date is later than the second, a negative number is returned:

``````date1 = "19.05.1983"
date2 = "16.05.1983"
``````
``````date_difference(#date1, #date2)
``````
``````-3
``````

## #`date_format(date)`

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

``````date_string = "16.05.1983"
``````
``````date_format(#date_string)
``````
``````"dd.MM.yyyy"
``````

WARNING

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 (opens new window).

``````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
``````

## #`endswith(string, end)`

Checks if `string` ends with string `end` (upper/lower case must match). Returns true if `end` is empty.

This is equivalent to `substring(#string, len(#string) - len(#end)) == #end`.

``````value = "foobaz"
``````
``````endswith(#value, "baz")
endswith(#value, "BAZ")
endswith(#value, "")
``````
``````true
false
true
``````

## #`filter(list)`

Removes items from a list if they meet one of the following criteria:

• item is empty ("", [], {} - String, List, Object)
• item is False (Boolean)
• item is a Phrase Node that returns the value False using has_voc(Phrase Node)
``````various_items = ["", 1, "a", {"examplekey": ""}, "", [], {}]
``````
``````filter(#various_items)
``````
``````[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.

``````models = [{
"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"
},{
"Price": "\$692.68",
"Ram": "4 GB"}]
``````
``````filter(#models, {"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"
}]
``````

WARNING

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

Input and output list same as above.

``````models
``````
``````filter(#models, [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

WARNING

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.

``````models
``````
``````filter(#models, [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

WARNING

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)`

Get a range of elements from a list.
A positive `number` will return the first n elements of the list, a negative `number` will return the last n elements of the list.

If the list has less than `number` elements, returns the full list.
If `number` is 1 or -1, returns the first or last item, without wrapping it in a list.

TIP

See range() or slice() if you do not want above behavior, or if you need a slice from the middle of a list.

``````items = [ 1, 2, 3, 4, 5 ]
``````
``````first(#items, 3)
first(#items, -3)
``````
``````[1, 2, 3]
[3, 4, 5]
``````
``````items = [ 1, 2, 3, 4, 5 ]
``````
``````first(#items, 5)
first(#items, 6)
``````
``````[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
``````

WARNING

Output is the full list for 5 and above.

``````items = [ "a", "b", "c" ]
``````
``````first(#items, 1)
first(#items, -1)
``````
``````"a"
"c"
``````

## #`flatten(nested_list)`

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

TIP

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)`

Format a number for the current locale, using the minimal number of decimal digits.

Assuming locale is de-DE:

``````format_number(10/3)
format_number(2/5)
format_number(3)
``````
``````"3,333"
"0,4"
"3"
``````

See group_digits() to also add thousand separators.

## #`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
``````

WARNING

Output uses locale en-US.

Input same as above.

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

WARNING

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"
``````

WARNING

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",
"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",
"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,
"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 ]
}
``````

WARNING

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"
}]
}
``````

WARNING

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.

``````number = 6
``````
``````in_range(#number, 5, 10)
``````
``````true
``````
``````number = 12
``````
``````in_range(#number, 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
``````

WARNING

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

## #`is_list(value)`

Checks if `value` is a list.

``````is_list("foo")
is_list(["foo"])
is_list({"a": "b"})
``````
``````False
True
False
``````

## #`is_numeric(value)`

Checks if `value` is a number, or can be cast to one.

``````is_numeric(3.4)
is_numeric(" 3.4 ")
is_numeric("")
is_numeric("foo")
``````
``````True
True
False
False
``````

WARNING

This function returns False exactly if numeric() would throw an error, except for the empty string which numeric() would convert to 0.

## #`is_object(value)`

Checks if `value` is an object.

``````is_object("foo")
is_object(["foo"])
is_object({"a": "b"})
``````
``````False
False
True
``````

## #`join(list[, delimiter])`

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

``````items = [1, 2, 3, 4, 5]
``````
``````join(#items)
``````
``````"12345"
``````
``````items = [1, 2, 3, 4, 5]
``````
``````join(#items, "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.

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

WARNING

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

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

WARNING

## #`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.

``````numbers = [1, 2, 3]
``````
``````map(#numbers, [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 thepicked element(name must match ) + 2 math: add 2 ] notation

``````products = [
{"Brand": "Xiaomi", "Model": "Mi Mix"},
{"Brand": "OnePlus", "Model": "OnePlus 3T A3010"},
{"Brand": "Huwawei", "Model": "Huawei Mate 9 Pro"}
]
``````
``````map(#products, [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.

``````products = [
{"Brand": "Xiaomi", "Model": "Mi Mix"},
{"Brand": "OnePlus", "Model": "OnePlus 3T A3010"},
{"Brand": "Huwawei", "Model": "Huawei Mate 9 Pro"}
]
``````
``````map(#products, [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

WARNING

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

``````brands = ["Brand", "Model"]
models = ["Xiaomi", "Mi Mix"]
``````
``````map(#brands, [entry, index, content -> #entry + " (" + #content[#index] + ")"], #models)
``````
``````["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

WARNING

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 (`brands`) to access the value at the same index of the second list (`models`).

## #`max(list)`

Returns the maximum value from a list of numerics.

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

## #`min(list)`

Returns the minimum value from a list of numerics.

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

## #`month_no(string)`

Returns the month name in a numeric representation.

WARNING

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.

WARNING

AND concatenation of the search parameters

``````products = [
{
"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"
},{
"Price": "\$692.68",
"Ram": "4 GB"
}]
``````
``````neg_filter(#products, {"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"
},{
"Price": "\$692.68",
"Ram": "4 GB"
}]
``````

WARNING

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.

``````products
``````
``````neg_filter(#products, {"Ram": "6 GB"})
``````
``````[{
"dummykey": "dummyvalue"
},
{
"Brand": "Xiaomi",
"Model": "Mi Mix",
"Price": "\$482.99",
"Ram": "4 GB"
},
{
"Price": "\$692.68",
"Ram": "4 GB"
}]
``````

WARNING

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.

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

WARNING

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.

``````products
``````
``````neg_filter(#products, [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"
}]
``````

WARNING

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

``````products = [{
"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(#products, [entry, index, context -> #entry.Brand == #context.examplelist[#index] ], {"examplelist": ["OnePlus", "Google"]})
``````
``````[{
"Brand": "Xiaomi",
"Model": "Mi Mix",
"Price": "\$482.99",
"Ram": "4 GB"
}]
``````

WARNING

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

## #`object_add(object, object)`

Copies the first object, and add or overwrite all keys from the second one.

TIP

This is equivalent to `object(list(#first_object) + list(#second_object))`.

``````source_object = { "x": 1, "y": 2 }
``````
``````object_add(#source_object, {"z": 3})
``````
``````{ "x": 1, "y": 2, "z": 3 }
``````

If a key exists in both objects, the value of the second object wins:

``````object = { "x": 1, "y": 2 }
``````
``````object_add(#object, {"y": "foo"})
``````
``````{ "x": 1, "y": "foo" }
{ "x": 1, "y": 2 }
``````

As alternative to an object, the function also accepts a list of key-value pairs:

``````object = { "x": 1, "y": 2 }
update = [["y", 3], ["index", 4]]
``````
``````object_add(#object, #update)
``````
``````{ "x": 1, "y": 3, "index": 4 }
``````

## #`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"
}
``````

## #`pow(a, b)`

Returns a to the power of b. Fractional and negative exponents are supported:

``````pow(2, 3)    # same as 2 * 2 * 2
pow(2, 0.5)  # same as sqrt(2)
pow(10, -3)  # same as 1 / 1000
``````
``````8
1.41421356
0.001
``````

## #`random_el(list, number)`

This method returns random elements from a list.

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

Passing the length of the list can be used to shuffle:

``````list = [1, 2, 3, 4, 5]
``````
``````random_el(#list, 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)

TIP

See slice() if a start and end argument is more convenient for your use case.

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"]
[]
``````

## #`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").

WARNING

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, anchor, offset)`

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
• anchor - start search from left (`"l"`) or right (`"r"`) end of the list; default `"l"`
• offset - number of elements to skip (counting from anchor); default `0`
``````list = [1, 2, 30]
``````
``````re_find(#list, "3")
``````
``````"30"
``````
``````list = [1, 2, 13, 14]
``````
``````re_find(#list, "1.*", "l", 0)
re_find(#list, "1.*", "l", 2)
re_find(#list, "1.*", "r", 0)
re_find(#list, "1.*", "r", 2)
``````
``````"1"
"13"
"14"
"1"
``````
``````list = ["a", "b", "c"]
``````
``````re_find(#list, "d")
``````
``````""
``````

## #`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)

WARNING

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
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_keep(#list, "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
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_keep(#list, "xyz.", "l", 1)
``````
``````["xyz1"]
``````
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_keep(#list, "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
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_remove(#list, "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
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_remove(#list, "abc", "l", 1)
``````
``````["xyz1", "xyz2"]
``````
``````list = ["xyz1", "abc", "xyz2"]
``````
``````re_remove(#list, "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.

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

The replacement string can include the following special replacement patterns:

Pattern Effect
`\$\$` Inserts a literal "\$" (only needed if followed by a number)
`\$0` or `\$&` Inserts the matched substring
`\$1``\$9` Inserts the nth parenthesized submatch string
``````value = "abc 1234 def 5678"
``````
``````re_replace(#value, "([0-9])([0-9]+)", "+\$1\$1 \$2")
``````
``````"abc +11 234 def +55 678"
``````

## #`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
``````

## #`reduce(list, lambda_expression, initial_value)`

Executes a reducer function on each element of the list, resulting in a single output value.

For example, `reduce(#list, [a, b -> #a + #b], 0)` is equivalent to `sum()`.

This works with an internal value called the accumulator, which is first set to `initial_value`. Then the given lambda is called with arguments `[accumulator, item]` for each item of the list. The accumulator is set to the lambda's return value, and its final value is returned.

If the list is empty, initial_value will be returned without calling the function.

An example execution of `reduce([2, 3, 4], [acc, x -> #acc * x], 1)`:

 callback iteration accumulator item return value first call 1 2 1 * 2 = 2 second call 2 3 2 * 3 = 6 third call 6 4 6 * 4 = 24
``````reduce([2, 3, 4], [acc, x -> #acc + #x], 0)  # 9
reduce([2, 3, 4], [acc, x -> #acc * #x], 1)  # 24
``````

Its true flexibility is that it can be used with any operator or function:

``````data = [{"a": 1}, {"b": 2}, {"c": 34}]
``````
``````reduce(#data, [acc, x -> object_add(#acc, #x)])
``````
``````{"a": 1, "b": 2, "c": 34}
``````

WARNING

Contrary to `reduce()` in e.g. Javascript, omitting the initial_value argument will not default it to the first item of the list, but rather `""`. We recommend that you always give an initial value.

## #`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(number)`

Round `number` to the next whole number. In case of .5, round towards the next even number ("banker's rounding").

``````round(0.6)
round(2.5)
round(3.5)
``````
``````1
2
4
``````

## #`round(number, decimals[, mode])`

Round `number` to the given number of decimal places (0 to round to a whole number).
The optional parameter mode selects a rounding behavior:

• `"up"`: Round away from zero
• `"down"`: Round towards zero
• `"half_up"`: Round to nearest digit, with .5 going away from zero.
• `"half_down"`: Round to nearest, with .5 going towards zero.
• `"half_even"`: Round to nearest, with .5 going towards next even number ("banker's rounding", the default)
``````#num = 0.144743575
``````
``````round(#num, 3)
round(#num, 2)
round(3.85, 1)
round(3.75, 1)
``````
``````0.145
0.14
3.8
3.8
``````

Rounding modes:

``````round(3.2, 0, "up")
round(3.8, 0, "down")
round(2.5, 0, "half_up")
round(3.5, 0, "half_down")
round(3.85, 1, "half_even")
``````
``````4
3
3
3
3.8
``````

## #`slice(list, start[, end])`

Gets a slice of a list by providing a start- and endpoint.

TIP

See range() if an index and count argument is more convenient for your use case.

`start` and `end` are zero-based indices (0 meaning the first element, 1 the second, and so on), but can also be negative to count from the end of the list (-1 being the last element, and so on).

The function returns all list elements from `start` to just before `end` (which is not included). If `end` is omitted, returns all elements to the end of the list (the same could be done by supplying `count(#list)`).

``````items = [1, 2, 3, 4, 5]
``````
``````slice(#items, 1, 4)   # select index 1, 2, and 3
slice(#items, 2, -1)  # select from third to second-to-last
slice(#items, -2)     # select the last two elements
slice(#items, 1)      # omit the first element
slice(#items, -3, -1) # select third-to-last and second-to-last
``````
``````[2, 3, 4]
[3, 4]
[4, 5]
[2, 3, 4, 5]
[3, 4]
``````

In case `start` is later than `end`, or there are not enough elements, a shorter or empty list is returned:

``````items = [1, 2, 3, 4, 5]
``````
``````slice(#items, 2, 2)
slice(#items, -10)
slice(#items, 2, 10)
``````
``````[]
[1, 2, 3, 4, 5]
[3, 4, 5]
``````

## #`sort(list)`

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

``````unsorted_numbers = [4, 5, 3, 2, 1]
``````
``````sort(#unsorted_numbers)
``````
``````[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.

``````products = [{
"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"
},{
"Price": "692.68",
"Ram": "4 GB"
}]
``````
``````sort(#products, "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"
},
{
"Price": "692.68",
"Ram": "4 GB"
}
]
``````

WARNING

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

Example list of objects:

``````products = [{
"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"
},{
"Price": "692.68",
"Ram": "4 GB"
}]
``````
``````sort(#products, [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"
},
{
"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.

``````string_with_spaces = "string1 string2 string3"
``````
``````split(#string_with_spaces)
``````
``````["string1", "string2", "string3"]
``````
``````string_with_commas = "string1, string2, string3"
``````
``````split(#string_with_commas, ", ")
``````
``````["string1", "string2", "string3"]
``````

## #`sqrt(number)`

Returns the square root of `number`.

``````sqrt(2)
``````
``````1.414213562373
``````

## #`startswith(string, start)`

Checks if `string` begins with string `start` (upper/lower case must match). Returns true if `start` is empty.

This is equivalent to `substring(#string, 0, len(#start)) == #start`.

``````value = "foobaz"
``````
``````startswith(#value, "foo")
startswith(#value, "FOO")
startswith(#value, "")
``````
``````true
false
true
``````

## #`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"
``````

WARNING

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

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

WARNING

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

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

WARNING

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.

``````numbers = [1, 2, 3]
``````
``````sum(#numbers)
``````
``````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.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"
``````

WARNING

Nothing to trim

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

WARNING

Stripped whitespace from the beginning

Example data param1:

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

WARNING

stripped whitespace from the end

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

WARNING

Stripped whitespace from the beginning and the end

## #`unique(list)`

Finds the unique elements of a list.

The list elements must be strings or numbers. Nested lists are supported for convenience, and will be treated as a single flat list. The result is in the same order as the input, i.e. sorted by the element's first occurrence.

TIP

If you also need the number of repeated elements, see count_uniques().

``````list = [1, 2, 3, 1, 2]
``````
``````unique(#list)
``````
``````[1, 2, 3]
``````

Using a nested list:

``````list = ["cat", "dog", "cat"]
``````
``````unique([#list, 14, 10, 12, 10])
``````
``````["cat", "dog", 14, 10, 12]
``````

## #`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
``````weekday_int(1)
``````
``````2  # on Monday
``````

WARNING

The function returns the weekday of tomorrow: Assuming today is Monday (1), it gives 2 (Tuesday)

``````days_to_add = 6
``````
``````weekday_int(#days_to_add)
``````
``````1  # on Tuesday
``````

WARNING

Assuming today is Tuesday (2), in six days it will be Monday (1).

## #`weekday_no(day)`

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

WARNING

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

``````weekday = "Tuesday"
``````
``````weekday_no(#weekday)
``````
``````2
``````

WARNING

Tuesday is the second day in a week.

``````weekday = "Monday"
``````
``````weekday_no(#weekday)
``````
``````1
``````

WARNING

Monday is the first day of the week.