I have problems with understanding recursion, I don't get the explanations in books and tutorials. The example below finds the greatest value in a list, here I get stuck at the second line, I simply don't understand what is happening after max([H|T], Max) when H > Max ->
I would really appreciate if I could get an explanation of all the steps in the code, for instance why it goes -> max(T, H);
and -> Max.
max([H|T]) -> max(T, H).
max([H|T], Max) when H > Max -> max(T, H);
max([_|T], Max) -> max(T, Max);
max([], Max) -> Max.
Many thanks! E.