Elixir Enum Flat Map

[Solved] Elixir Enum Flat Map | Elixir - Code Explorer | yomemimo.com
Question : elixir enum flat_map

Answered by : nguyen-quang-huy

Enum.flat_map([:a, :b, :c], fn x -> [x, x] end)
[:a, :a, :b, :b, :c, :c]
iex> Enum.flat_map([{1, 3}, {4, 6}], fn {x, y} -> x..y end)
[1, 2, 3, 4, 5, 6]
iex> Enum.flat_map([:a, :b, :c], fn x -> [[x]] end)
[[:a], [:b], [:c]]

Source : https://hexdocs.pm/elixir/1.12/Enum.html#flat_map/2 | Last Update : Fri, 14 Jan 22

Answers related to elixir enum flat map

Code Explorer Popular Question For Elixir