append()
Adds an element to the end of a list and returns the new list.
Syntax | append(<list>, <elem>) |
||
Arguments | Name | Type | Description |
<list> |
LIST |
The target list | |
<elem> |
Any | The element to be added | |
Return Type | LIST |
with ["a", 1, 2] as myList
return append(myList, "b")
Result:
append(myList, "b") |
---|
["a",1,2,"b"] |
difference()
Returns the difference between two lists, producing a new list of elements found in the first input list but not in the second. Duplicates are included.
Syntax | difference(<list_1>, <list_2>) |
||
Arguments | Name | Type | Description |
<list_1> |
LIST |
The first list | |
<list_2> |
LIST |
The second list | |
Return Type | LIST |
with [1,2,2,3] as l1, [3,4,5] as l2
return difference(l1, l2)
Result:
difference(l1, l2) |
---|
[1,2,2] |
head()
Returns the first element in a list.
Syntax | head(<list>) |
||
Arguments | Name | Type | Description |
<list> |
LIST |
The target list | |
Return Type | STRING |
with ["a", 1, 2] as myList
return head(myList)
Result:
head(myList) |
---|
a |
intersection()
Returns the intersection of two lists, producing a new list of elements common to both. Duplicates are included.
Syntax | intersection(<list_1>, <list_2>) |
||
Arguments | Name | Type | Description |
<list_1> |
LIST |
The first list | |
<list_2> |
LIST |
The second list | |
Return Type | LIST |
with [1,2,3,3] as l1, [3,3,4,5] as l2
return intersection(l1, l2)
Result:
intersection(l1, l2) |
---|
[3,3] |
listContains()
Checks whether a specified element exists in a list, returning 1
for true and 0
for false.
Syntax | listContains(<list>, <elem>) |
||
Arguments | Name | Type | Description |
<list> |
LIST |
The list to be checked | |
<elem> |
Any | The element to look for in <list> |
|
Return | 1 or 0 |
with ["a", 1, 2] as myList
return listContains(myList, "b")
Result:
listContains(myList, "b") |
---|
0 |
listUnion()
Returns the union of two lists, producing a new list of elements from either input list. Duplicates are removed.
Syntax | listUnion(<list_1>, <list_2>) |
||
Arguments | Name | Type | Description |
<list_1> |
LIST |
The first list | |
<list_2> |
LIST |
The second list | |
Return Type | LIST |
with [1,2,2,3] as l1, [3,4,5] as l2
return listUnion(l1, l2)
Result:
listUnion(l1, l2) |
---|
[1,2,3,4,5] |
reduce()
Performs a calculation iteratively using each element in a list. With a specified intital value, the defined calculation takes the first element in the list as input.
Syntax | reduce(<resAlias> = <initVal>, <elemAlias> in <list> | <calcExp>) |
||
Arguments | Name | Type | Description |
<resAlias> |
/ | The alias representing the initial, intermediate and final calculation result | |
<initVal> |
/ | The initial value assigned to <resAlias> |
|
<elemAlias> |
/ | The alias representing each element in the list | |
<list> |
LIST |
The target list | |
<calcExp> |
/ | The calculation expression | |
Return Type | STRING |
with [1,3,5] as myList
return reduce(_sum = 0, item in myList | _sum + item) AS listSum
Result:
listSum |
---|
9 |
size()
Returns the number of elements in a list.
Syntax | size(<list>) |
||
Arguments | Name | Type | Description |
<list> |
LIST |
The target list | |
Return Type | UINT |
with [1, 2, null, 3] as myList
return size(myList)
Result:
size(myList) |
---|
4 |