List functions
filter
filter(input_list, fn, tolerate_errors=false)
Filter a list based on whether a refiner function outputs
true or false for each value.
Args:
input\_list (list): list or list json\-encoded as a string
fn (str): name of function to be used for mapping.
tolerate\_errors (bool): should errors be allowed (with elements causing errors filtered out)?
Returns:
Returns a list of the filtered elements
Examples:
filter(\[' a', ' b '\], 'contains(x, \\'a\\')') \-> \[' a'\]
first
first(input_list)
Returns the first element of the list
Args:
input\_list (list): the list containing values
Returns:
The first element, or an error if it doesn't exist
Examples:
first(\['a', 'b', 'c'\]) \-> 'a'
first_or_default
first_or_default(input_list, default)
Returns the first element of the list, or the default value
if the list is empty
Args:
input\_list (list): the list containing values
default (any): the default value to use if list is empty
Returns:
The first element, or default if the list is empty
Examples:
first\_or\_default(\['a', 'b', 'c'\], 'd') \-> 'a'
first\_or\_default(\[\], 'd') \-> 'd'
flatten_list
flatten_list(nested_list)
Turn a nested list into a single list of all the elements which were
previously within its separate lists
Args:
nested\_list (list): nested list
Returns:
Returns a flattened list containing all of the elements in the list inputs
Examples:
flatten\_list(\[\['a', 'b'\], \['c'\]\]) \-> \['a', 'b', 'c'\]
last
last(input_list)
Returns the last element of the list
Args:
l (list): the list containing values
Returns:
The last element, or an error if it doesn't exist
Examples:
last(\['a', 'b', 'c'\]) \-> 'c'
last_or_default
last_or_default(input_list, default)
Returns the last element of the list, or the default value
if the list is empty
Args:
input\_list (list): the list containing values
default (any): the default value to use if list is empty
Returns:
The last element, or default if the list is empty
Examples:
last\_or\_default(\['a', 'b', 'c'\], 'd') \-> 'c'
last\_or\_default(\[\], 'd') \-> 'd'
list
list(*args: Any)
Creates a list from all the arguments
Args:
args (list): Variable length arguments
Returns:
Returns a list
Examples:
list('a', 'b', 'c') \-> \['a', 'b', 'c'\]
list_get
list_get(input_list, n, default=None)
Returns n-th element of the list
Args:
input\_list (list): the list containing values
n (int): the zero\-indexed index to be returned
default (any): the default value to return if there is no nth index. Defaults to None
Returns:
Returns n\-th element of the list, or default if it doesn't exist
Examples:
list\_get(\['a', 'b', 'c'\], 0) \-> 'a'
list_get_range
list_get_range(input_list, rng)
Returns a range of elements from a list
Args:
l (list): the list containing values
rng (str): a range of list items to return, represented as a python array range
Returns:
Returns the list of elements in the specified range
Examples:
list\_get\_range(\['a', 'b', 'c'\], '1:2') \-> \['b'\]
list\_get\_range(\['a', 'b', 'c'\], '1:') \-> \['b', 'c'\]
list\_get\_range(\['a', 'b', 'c'\], '-1:') \-> \['c'\]
list\_get\_range(\['a', 'b', 'c'\], '100:') \-> \[\]
map
map(input_list, fn, tolerate_errors=false)
Operate on a list by transforming each element using a refiner function
Args:
input\_list (list): list of element to be operated on. Can also be a string which decodes to a json list
fn (str): name of function to be used for mapping
tolerate\_errors (bool): should errors be allowed (elements throwing errors are filtered out)
Returns:
Returns a list of the mapped elements
Examples:
map(\[' a', ' b '\], 'contains(x, \\'a\\')') \-> \[True, False\]
map(\[' a', ' b '\], 'echo(\\'1\\', x, \\'2\\')') \-> \['1 a2', '1 b 2'\]
merge_lists
merge_lists(*args: Any)
Merges several lists into a single list
Args:
args (str): Variable length arguments: the lists to merge
Returns:
a single list
Examples:
merge\_lists(\['a', 'b'\], \['c'\]) \-> \['a', 'b', 'c'\]