Two clause definition to find the maximum number on a list
prolog
Solution
As you, I use the 'max' name for the predicate. This implementation don't rely in any built-in predicate:
max([X],X).
max([X|Xs],X):- max(Xs,Y), X >=Y.
max([X|Xs],N):- max(Xs,N), N > X.
Problem
How would I write a two clause recursive definition to find the maximum value in a list. So far I have written this: ``` max(L,M):- max([H|T],M):- max(T,H,M). max([],M,M). max([H|T],Y,M):- H =< Y, max(T,Y,M). max([H|T],Y,M):- H > Y, max(T,H,M). ``` This doesn't work, it says there is a syntax error which I can't quite see, and I know it isn't two clause either. Anyone know how I could simplify it to make it two clause?