Skip to content

Instantly share code, notes, and snippets.

@hauleth hauleth/advent1.exs
Created Dec 2, 2017

What would you like to do?
defmodule Advent1 do
def sum([h|_]=list),do: do_sum(list++[h],0)
defp do_sum([_],sum),do: sum
defp do_sum([a|[a|_]=rest],sum),do: do_sum(rest,sum+a-?0)
defp do_sum([_|rest],sum),do: do_sum(rest,sum)
IO.puts Advent1.sum to_charlist :all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.