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

Hint

The general idea is as follows: we use the accumulator to pass on the greatest element that we have found so far. For non-empty lists, compare the the head of the list to the accumulator. If it is greater the head should become the new accumulator that we use in the recursive call for computing the greatest element of the tail; otherwise the accumulator is just passed on. Once we reach the empty list, the accumulator will contain the maximal element. So, the result argument can be instantiated with this value.

In addition to the 3-place recursive predicate with accumulator, you also need to write a 2-place wrapper predicate which calls the 3-place predicate and provides an initial instantiation for the accumulator.

Solution

Back to the exercise.