In Prolog, in order to process the elements of a list, we have to match them to variables. The method for doing is
We get the head by matching it to a variable. By calling a predicate with the variable, it processes the head. Until you get an empty list repeat the above steps.