Sentinel
Import: collection/lists
The collection/lists
import provides helpers for working with lists.
concat
concat(items, others[, ...additional])
Join multiple lists together, returning the resulting list. This helper must have at least two arguments supplied. Order is important, as the order of arguments is the order that lists will be appended.
Arguments
Name | Description |
---|---|
items | the first list to add to the resulting value |
others | the second list to add to the resulting value |
additional | any number of additional lists to add to the resulting value |
Examples
Concatenate two lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
Concatenate many lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
difference
difference(items[, ...additional])
Difference returns a new list with all values that exist in the first list that are not present in all remaining provided lists.
Arguments
Name | Description |
---|---|
items | the first list, used as the source for ordering |
additional | any number of additional lists used to subtract from the source list |
Aliases
diff
Examples
Difference between two lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
Difference between many lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
intersection
intersection(items[, ...additional])
Intersection returns a list consisting of unique values that are present in all of the provided lists.
Arguments
Name | Description |
---|---|
items | the first list to use for intersection |
additional | any number of additional lists used to intersect |
Examples
Intersection between three lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
sort
sort(items, sort_function)
Sort will sort a list of elements according to the provided sort function, returning a new, sorted list.
Arguments
Name | Description |
---|---|
items | the list to sort |
sort_function | the function that is used to perform the sort |
Sort Function
The provided sort function accepts two arguments, which can be considered as the
current
and next
item. The function should return one of the following values:
Result | Description |
---|---|
-1 | current is less than next |
0 | current is equal to next |
+1 | current is greater than next |
The compare built-in method provides a way of performing comparisons against integers, floats or strings to return a supported value.
Examples
Sort a list of words:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
Sort a list of objects by a key:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
sum
sum(items)
Sum will add all elements within the provided list. The list must only contain integers or floats. The return value will always be a float.
Arguments
Name | Description |
---|---|
items | the list to sum |
Examples
Perform a sum on a list of numbers:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
union
union(items[, ...additional])
Union will return a list that contains unique values from all provided lists.
Arguments
Name | Description |
---|---|
items | the first list of values |
additional | any number of additional lists of values |
Examples
Perform a union on multiple lists:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output