O'Reilly logo
  • Pavel Shaydo thinks this is interesting:

So far you’ve seen how to process each element in a list, but what if we want to sum all of the elements? The difference here is that we need to remember the partial sum as we process each element in turn.

From

Cover of Programming Elixir 1.3

Note

why is that? sum([head|tail]), do head+sum(tail) would work. Is it because of tail call optimization?