I have defined some custom constraints like that:
constraint(a,something).
constraint(a,something1).
constraint(a,something2).
and i need this logical conjunction of them all as a result. ( if one constraint fails, the result should fail )
result(X) :-
constraint(X,something),
constraint(X,something1),
constraint(X,somethingElse).
I'm looking for a more convenient way to avoid this explicit coding of all constraints.
result(X) :- ????
At some point, you need a predicate somewhere to actually list all the constraints you wish to apply. You could do something like this:
This mechanism allows you to generate the constraints dynamically as a list, if desired. You could also have the list of constraints be a fact:
And then use that in the
result
predicate: