Question: What's an optimal way to convert this hash:

```
%{
    "0" => [
        %{"foo" => 1, "baz" => 10}
    ], 
    "1" => [
        %{"foo" => 2, "baz" => 11}
    ]
}

```

to a list like this?

```
[
    %{"foo" => 1, "baz" => 10},
    %{"foo" => 2, "baz" => 11}
]

```

Answer: 
While [`Map.values/2`](https://hexdocs.pm/elixir/master/Map.html#values/2) would definitely work, the [`Kernel.SpecialForms/1`](https://hexdocs.pm/elixir/master/Kernel.SpecialForms.html#for/1) comprehension is probably a more flexible way to go since it allows you to filter and/or modify the result in-place.

```rb
input = %{
  "0" => [
    %{"foo" => 1, "baz" => 10}
  ], 
  "1" => [
    %{"foo" => 2, "baz" => 11}
  ]
}

for {_, [map]} <- input, do: map
#⇒ [%{"baz" => 10, "foo" => 1}, %{"baz" => 11, "foo" => 2}]

```

In case you expect to have *more* than one element in each list in values, use [`Enum.reduce/3`](https://hexdocs.pm/elixir/master/Enum.html#reduce/3):

```rb
Enum.reduce(input, [], fn {_, maps}, acc -> acc ++ maps end)
#⇒ [%{"baz" => 10, "foo" => 1}, %{"baz" => 11, "foo" => 2}]

```

---

Another possibility would be to use [`Enum.flat_map/2`](https://hexdocs.pm/elixir/master/Enum.html#flat_map/2):

```rb
Enum.flat_map(input, &elem(&1, 1))
#⇒ [%{"baz" => 10, "foo" => 1}, %{"baz" => 11, "foo" => 2}]

```

---

FWIW, the solution with `Map.values/1` (not recommended):

```rb
input
|> Map.values()
|> Enum.flat_map(& &1)
#⇒ [%{"baz" => 10, "foo" => 1}, %{"baz" => 11, "foo" => 2}]

```
```
original = %{
    "0" => [
        %{"foo" => 1, "baz" => 10}
    ], 
    "1" => [
        %{"foo" => 2, "baz" => 11}
    ]
}

values_from_original = original |> Map.values

result = for e <- values_from_original, do: e |> Enum.at(0)

```