I have a program in SICStus Prolog that runs the following constraints:
processList([Elem1,Elem2|_], X) :-
(Elem1 #= 0 #/\ Elem2 #= X) #\/
Elem1 #= X.
But I need to have it set up dynamically
processList([Elem1,Elem2,Elem3|_], X) :-
(Elem1 #= 0 #/\ Elem2 #= 0 #/\ Elem3 #= X) #\/
(Elem1 #= 0 #/\ Elem2 #= X) #\/
Elem1 #= X.
And if I call it with 4 elements I will have a bigger restriction, but the pattern is always the same.
I have already looked into the table predicate (tuples_in/2
, in SWI-Prolog), but that creates the need of me having to calculate all the possible valid combinations of values.
Is there any other way I can do this?