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

Solution

%% If the list is empty, it's length is obviously 0.
list_length([],0).

%% If the length of the tail is TailLength, then the length
%% of the tail plus the head is TailLength plus 1.
list_length([Head|Tail],Length) :-
           list_length(Tail,TailLength),
           Length is TailLength + 1.
    
Download the knowledge base here.

Back to the exercise.