Using Elixir pipeline to transform a string into a map Consider the list of string values,

lines = ["foo: 1", "bar: 2", "baz: 3"]


That one might transform into the Elixir map,

%{ "foo": "1", "bar": "2", "baz": "3"}


using a simple Enum.reduce,

Enum.reduce(lines, %{}, fn(line, result) -&gt;
  [key, value] = String.split(line, ": ")
  Map.put(result, key, value)
end)


How might one refactor this into something more succinct, specifically with the third argument passed to reduce? For example, my instinct wants to do something like,

Enum.reduce(lines, %{}, fn(line, result) -&gt;
  String.split(line, ": ") |&gt; Map.put(result)
end)


but the Elixir pipe operator doesn't allow piping multiple values nor piping them to anything other than the first argument.
You can do this with an anonymous function

Enum.reduce(lines, %{}, fn(line, result) -&gt;
  String.split(line, ": ")
  |&gt; (fn(x) -&gt; Map.put(result, hd(x), List.last(x)) end).()
end)


You can also do it like this 

Enum.reduce(lines, [], fn(line, result) -&gt; result ++ String.split(line, ": ") end)
  |&gt; Enum.chunk(2)
  |&gt; Map.new(fn [k,  v] -&gt; {k, v} end)


which I less efficient, because it does 2 iterations, but I think it looks cleaner.