Reputation: 315
Is there a way to get a list by results of a query?
eg:
getPairs(x,y):-
v1(x), v2(y);
v11(x), v22(y).
v1(10). v2(20). v11(12). v22(22).
then how can i use getPairs to make a list of pairs that I could then feed into another query
[[10,20],[12,22]].
Upvotes: 0
Views: 48
Reputation: 1813
You were almost there
getPairs([[X1,X2], [Y1,Y2]):-
v1(X1), v2(X2),
v11(Y1), v22(Y2).
v1(10). v2(20). v11(12). v22(22).
In getPairs/1, you write what pattern you want as result. Note that logic variables are written with capitals.
Upvotes: 1