Last active
July 9, 2016 01:08
-
-
Save fschuindt/09514c982cb427058331b62009eed45f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Math do | |
def sum_list(list, accumulator \\ 0) | |
def sum_list([head | tail], accumulator) do | |
sum_list(tail, head + accumulator) | |
end | |
def sum_list([], accumulator) do | |
accumulator | |
end | |
end | |
IO.puts Math.sum_list([1, 2, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment