How to sum a list with Elixir with recursion?

Sum a list with Elixir

defmodule M do
def sum([h | t]) do
h + sum(t)
end
def sum([]) do
0
end
end

Then, when we pass list to function sum of module M we get

M.sum([1, 2, 3, 4, 5])
15