Appends an element to the end of the list and returns the updated list.
| Syntax | append(<list>, <elem>) | ||
| Arguments | Name | Type | Description |
<list> | LIST | The target list | |
<elem> | Any | The element to be added | |
| Return Type | LIST | ||
UQLwith ["a", 1, 2] as myList return append(myList, "b")
Result:
| append(myList, "b") |
|---|
| ["a",1,2,"b"] |
Returns the difference between two lists, generating a new list of elements found in the first list but not in the second. Duplicates are preserved.
| 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 | ||
UQLwith [1,2,2,3] as l1, [3,4,5] as l2 return difference(l1, l2)
Result:
| difference(l1, l2) |
|---|
| [1,2,2] |
Returns the first element in a list.
| Syntax | head(<list>) | ||
| Arguments | Name | Type | Description |
<list> | LIST | The target list | |
| Return Type | STRING | ||
UQLwith ["a", 1, 2] as myList return head(myList)
Result:
| head(myList) |
|---|
| a |
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 | ||
UQLwith [1,2,3,3] as l1, [3,3,4,5] as l2 return intersection(l1, l2)
Result:
| intersection(l1, l2) |
|---|
| [3,3] |
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 | ||
UQLwith ["a", 1, 2] as myList return listContains(myList, "b")
Result:
| listContains(myList, "b") |
|---|
| 0 |
Returns the union of two lists as a new list containing elements from either input. 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 | ||
UQLwith [1,2,2,3] as l1, [3,4,5] as l2 return listUnion(l1, l2)
Result:
| listUnion(l1, l2) |
|---|
| [1,2,3,4,5] |
Performs a calculation iteratively using each element in a list. With a specified initial value, the defined calculation takes the first element of 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 | ||
UQLwith [1,3,5] as myList return reduce(_sum = 0, item in myList | _sum + item) AS listSum
Result:
| listSum |
|---|
| 9 |
Returns the number of elements in a list.
| Syntax | size(<list>) | ||
| Arguments | Name | Type | Description |
<list> | LIST | The target list | |
| Return Type | UINT | ||
UQLwith [1, 2, null, 3] as myList return size(myList)
Result:
| size(myList) |
|---|
| 4 |