1 defmodule MyList do 2 3 def max(list), do: _max(list, 0) 4 5 defp _max([], max), do: max 6 7 defp _max([head | tail], max) do 8 _max(tail, (head > max && head) || max) 9 end 10 end
1 defmodule MyList do 2 3 def max(list), do: _max(list, 0) 4 5 defp _max([], max), do: max 6 7 defp _max([head | tail], max) do 8 _max(tail, (head > max && head) || max) 9 end 10 end