pyfunctools.flat_map module
- pyfunctools.flat_map.flat_map(arr: list, func) list[source]
Applies a function to each element in the list and flattens the result
- Parameters:
arr (list) – a list to iterate
func (function) – a callback function that returns a list for each element
Examples
>>> numbers = [1, 2, 3, 4] >>> flat_map(numbers, lambda x: [x, x * 2]) [1, 2, 2, 4, 3, 6, 4, 8]