Skip to content

Instantly share code, notes, and snippets.

@zacck-zz
Created October 26, 2017 09:40
Show Gist options
  • Save zacck-zz/a5778b338388bfd60dbbdd375c862b25 to your computer and use it in GitHub Desktop.
Save zacck-zz/a5778b338388bfd60dbbdd375c862b25 to your computer and use it in GitHub Desktop.
prices = [12,45,78,90]
defmodule Total do
def totaller([h|t],tot) do
totaller(t, tot+h)
end
def totaller([],tot), do: tot
end
IO.puts Total.totaller(prices, 0)
# => 225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment