In this situation we require that the elements of a list all satisfy some property. Here is the general schema:
test_all_have_property( Info []).Again the expression Info stands for a specific number of parameters that carry information needed for the determination that an individual element has the desired property. The remaining argument is the recursion argument. We illustrate with a predicate digits/1 for testing that a list of elements consists of digits only. We assume that we have mode all_digits(+).test_all_have_property( Info [Head
Tail]):-
element_has_property( Info Head)
test_all_have_property( Info Tail).
all_digits([]).This predicate has a declarative reading that a list has the property of consisting of digits if the first element is a digit and the tail of the list has the property of consisting of digits.all_digits([Head
Tail]):-
member(Head [0 1 2 3 4 5 6 7 8 9])
all_digits(Tail).
plus definition of member/2.
Note that we can make this fit the schema better if the term [0 1 2 3 4 5 6 7 8 9] is passed in as a parameter.