General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

Hint

The general strategy for finding the maximum of a list is to compute the maximum of the tail and then to compare the result with the head of the list. Whichever is bigger is the maximum of the whole list.
(You will need to rules to encode this: one to deal with the case where the head is greater than the maximum of the tail and one for the reverse case.)

But what is the base case for this predicate? Having done all the previous exercises, you will probably first think of the empty list. But what is the maximum of the empty list? It's not defined. But how about using a list with exactly one element for the base case?

Solution

Back to the exercise.