map_collection#
- composer.utils.map_collection(collection, map_fn)[source]#
Applies
map_fnon each element incollection.If
collectionis a tuple or list of elements,map_fnis applied on each element, and a tuple or list, respectively, containing mapped values is returned.If
collectionis a dictionary,map_fnis applied on each value, and a dictionary containing the mapped values is returned.If
collectionisNone,Noneis returned.If
collectionis a single element, the result of applyingmap_fnon it is returned.
- Parameters
collection โ The element, or a tuple of elements.
map_fn โ A function to invoke on each element.
- Returns
Collection โ The result of applying
map_fnon each element ofcollection.The type of ``collection`` is preserved.