I recently started Erlang, and I notice I constantly get "Warning: variable X is unused" while compiling. For example, take the following function, which finds the maximum element in a list:
max([Head|Tail]) ->
max(Head,Tail).
max(Element,[Head | Tail]) when Element < Head ->
max(Head,Tail);
max(Element,[Head | Tail]) ->
max(Element, Tail);
max(Element,[]) ->
Element.
The compiler warns me that in the 3rd case of the function, Head is unused. How can the function be written without Head?