Skip to content

Instantly share code, notes, and snippets.

@houmanka
Created March 19, 2020 09:22
Show Gist options
  • Save houmanka/9bae548978f8226ae6ffad9af06fa7e6 to your computer and use it in GitHub Desktop.
Save houmanka/9bae548978f8226ae6ffad9af06fa7e6 to your computer and use it in GitHub Desktop.
Counter with no Enum
defmodule AncientEgyptianMultiplication do
def count_of([_head | tail]) do
count_of(tail, 1)
end
def count_of([], state), do: state
def count_of([_head | tail], state) do
count_of(tail, state + 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment