Skip to content

Instantly share code, notes, and snippets.

@rin
Created August 23, 2013 12:01
Show Gist options
  • Save rin/6318576 to your computer and use it in GitHub Desktop.
Save rin/6318576 to your computer and use it in GitHub Desktop.
Programming Elixir, Chapter 7.6, Exercise ListsAndRecursion-2
defmodule MyList do
def max([]), do: nil
def max([head | []]), do: head
def max([head | tail]) do
_max(head, max(tail))
end
defp _max(a, b), do: (if a > b, do: a, else: b)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment