The utility predicates in this section can be used to apply a given predicate iteratively to one or more lists. This is an extension of the apply_macros library which saves a lot of typing for many constraint problems, because the iteration over the lists does not have to be explicitly repeated each time a new operation has to be performed.
For each list element we call diff1/2 with the second argument being the whole list without this element. diff1/2 delays until its first argument is instantiated, and then it calls Var #alldifferent(List) :- apprest(diff1, List). delay diff1(V, _) if var(V). diff1(Var, Vars) :- #\=(Var) apply_to [Vars].
\
= El for each element
of this list.