The first was not ok. When backtracking, the result could not be maintained. I finished with the program way before the deadline, so I wrote another predicate (an iterative method - the max is actually the maxOfTwo I have above) for finding max element of a list in prolog. Here it is:
Where did you have to write prolog brewbuck? I mean where prolog was helpful for you?
maxlist1([X | List], Max):-
maxlist2(List, X, Max).
maxlist2(, Max, Max).
maxlist2([X | List], SoFarMax, Max):-
max(X, soFarMax, NewSoFarMax),
maxlist2(List, NewSoFarMax, Max).
/***** and the max, instead of the maxOfTwo I have above,
could be written like an if-else statement, with the cut we learned
at this course ********/
max(X, Y, X):- X >= Y, !.
max(X, Y, Y).