Collections Provider¶
Hooks that act on collections of items.
Hooks¶
Type | Description | Return |
---|---|---|
concat | Hook for concatenating a list of items. | list |
distinct | Hook for getting distinct items from a list. | Optional[list] |
list_key_values | Hook for getting a list of values from a list of maps based on a key. | Optional[list] |
range | Create a list of integers within a range, ie ->: range 3 1 -> [3,2,1]. If given one arg, then that is considered 'stop'. If given two args, they are 'start' and 'stop'. If given three args, the last arg is for how much to increment through range. | list |
sort | Hook for sorting complex lists, dicts, or items within a key both in place or as output. | Union[list, dict, NoneType] |
Examples¶
sort¶
Sort a list in place based on a reference to a key path list or keys in dict
stuff:
things:
- foo
- bar
- baz
in-place_>: sort stuff/things
# Argument is a list so it is output to key
output->: sort {{stuff.things}}
stuff:
things:
- bar
- baz
- foo
output:
- bar
- baz
- foo
concatenate¶
Concatenate two lists.
list_1_>: # Notice this is private block so won't be in output
- foo
- bar
list_2_>:
- stuff
- things
out->: concat {{list_1}} {{list_2}}
# Only `out` key now
out:
- foo
- bar
- stuff
- things
distinct¶
Get distinct members from a list. Can also operate on context.
list:
- stuff
- stuff
- things
compact->: distinct {{list}}
expanded:
->: distinct
src:
- stuff
- stuff
- things
list:
- stuff
- stuff
- things
compact:
- stuff
- things
expanded:
- stuff
- things
list_key_values¶
From a list of maps, get the values based on a key.
list_of_maps:
- stuff: things
foo: bar
- foo: baz
stuff: mo tings
list_key_values:
->: list_key_values list_of_maps
key: stuff
list_of_maps:
- stuff: things
foo: bar
- foo: baz
stuff: mo tings
list_key_values:
- things
- mo tings