I have created a predicate that will check whether all the items in a list satisfy a condition.
For this example, the predicate checks that all elements are in multiples of two Check_Multiples/1
, which works quite well.
How would I check to see what item could be added to the beginning or the end of the list, and still satisfy the predicate?
I am trying to make the return a list.
For example:
[2,4,6]
should return [8]
as (as the predicate does not allow 0)
[6,8,10]
should return [4,12]
Check_Multiples/1
, is properly defined with CLP(FD) and has well-defined rules what that predicate means, then this would simply be,begin_or_end(L, BE) :- append(L, [Y], L1), findall(X, (Check_Multiples([X|L]) ; Check_Multiples(L1)), BE).
. – lurkerbegin_or_end(L, BE) :- findall(X, (Check_Multiples([X|L]) ; append(L, [X], L1), Check_Multiples(L1)), BE).
– lurker