You need to add parentheses around the map_join arguments. Your code is currently interpreted as
[5, 6, 7, 3] |> Enum.reverse |> Enum.map_join("", &(Integer.to_string(&1) |> String.to_integer))
what do you want though
[5, 6, 7, 3] |> Enum.reverse |> Enum.map_join("", &(Integer.to_string(&1))) |> String.to_integer
Generally, you always need to use parentheses when you use captures inside a pipeline to avoid ambiguity. Capture can also be simplified to &Integer.to_string/1 :
[5, 6, 7, 3] |> Enum.reverse |> Enum.map_join("", &Integer.to_string/1) |> String.to_integer
But a simple Enum.join will do the same. If you look at the implementation , it will still convert integers to strings using the String.Chars protocol ..
[5, 6, 7, 3] |> Enum.reverse |> Enum.join |> String.to_integer
By the way, you can achieve the same without using strings at all:
[5, 6, 7, 3] |> Enum.reverse |> Enum.reduce(0, &(&2 * 10 + &1))
Oh, and then Integer.digits and Integer.undigits , which can be used to convert an integer to and from a list of numbers. It is not present in the current release, although it is in the 1.1.0-dev branch, so I suspect it will go into 1.1.0 . You can see the progress here .
[5, 6, 7, 3] |> Enum.reverse |> Integer.undigits