I want to construct a predicate which applies a certain constraint to every variable in a list, kind of like the "map" function in functional programming. Its logical semantics should be "for all X in List : P(X)". The following is close to what I want, but has a flaw: forall(X, Vars, P) :- (foreach(V, Vars), param(X,P) do copy_term((X,P), (Y,Q)), Y = V, call(Q) ). The problem is that the call to copy_term duplicates _every_ variable in P, not just X. So the following will not work. integers([N]), forall(X, [V1, V2, V3], X < N), N #= 3. The final binding of N does not effect V1, V2, V3 because they are each constrained with regard to a copy of N and not N itself. Malcolm -- "The modern man in revolt has become practically useless for all purposes of revolt. By rebelling against everything he has lost his right to rebel against anything." - G.K.Chesterton, OrthodoxyReceived on Wed Mar 28 2007 - 07:57:30 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST