Stream.flat_map
You're seeing just the function
flat_map
, go back to Stream module for more information.
Specs
flat_map(Enumerable.t(), (element() -> Enumerable.t())) :: Enumerable.t()
Maps the given fun
over enumerable
and flattens the result.
This function returns a new stream built by appending the result of invoking fun
on each element of enumerable
together.
Examples
iex> stream = Stream.flat_map([1, 2, 3], fn x -> [x, x * 2] end)
iex> Enum.to_list(stream)
[1, 2, 2, 4, 3, 6]
iex> stream = Stream.flat_map([1, 2, 3], fn x -> [[x]] end)
iex> Enum.to_list(stream)
[[1], [2], [3]]