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
编写max(list) 返回列表最大元素
原文:https://www.cnblogs.com/or2-/p/10930627.html