Reputation: 8988
The following pipe:
items
...
|> Stream.map(&process/1)
Generates this kind of structure:
[ [], [], [], [] ]
and I would like it to be a flatten list.
Without using streams I would just do:
|> Enum.map(&process/1)
|> List.flatten
But I would like to use it as a stream but cant figure out how to apply List.flatten and generate a Stream.
Upvotes: 0
Views: 684
Reputation: 9639
You could try using Stream.flat_map/2
, something this should help:
items
...
|> Stream.flat_map(&process/1)
This will keep processing element
s in your items
, and flatten
the results.
Hope that helps!
Upvotes: 2