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

Hint

Declarative: what should the input and the output list look like for the predicate add_n(In,Out) to be true? One possibility is that they are both empty. The other possibility is that the head of the output list corresponds to adding 1 to the head of the input list and that the tail of the output list corresponds to the input list where each element has been increased by 1.

More procedurally: add one to the head of the input list. The result becomes the head of the output list. Then treat the tail of the input list (which is again a list) in the same way as the input list. If the input list is empty, the output list should also be empty.

Solution

Back to the exercise.