Trying to understand how Elixir does Enum.reduce, I plugged it into a puts to watch the ouput. I'm not clear on why it executes the second list element first, instead of the first, and then steps through all of the others independently.
iex (30)> Enum.reduce([1,2,3,4], &(IO.puts("a#{&1} b#{&2}")))
a2 b1
a3 bok
a4 bok
(The a and b are just there to validate order)
Looking at the source, I'm thinking that it translates into
:lists.foldl(&IO.puts("a#{&1} b#{&2}"), 1, [2,3,4])
yielding the same result.
where 1 is the initial accumulator, and if I'd given it a function that gave it something to accumulate it would say something interesting other than "bok".
Inverting those initial values strikes me as an odd behavior though. How should I be thinking about the Reduce implementation?