Created
February 1, 2018 13:33
-
-
Save cored/393aaf48a9a8462879215091c0d605b0 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 Recurse do | |
def sum([head | tail], accu) do | |
sum(tail, accu + head) | |
end | |
def sum([], accu), do: accu | |
end | |
IO.puts "Total: #{Recurse.sum([1,2,3,4,5], 0)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment