I’m trying to define a predicate that receives a single term with free variables and returns a list of mappings of those variables, so for example if the database is
a(0,1).
a(1,1).
the expected output would be
?- eval(a(X,1),Maps).
Maps = [[[X,0]],[[X,1]]].
?- eval(a(X,Y),Maps).
Maps = [[[X,0],[Y,1]],[[X,1],[Y,1]]].
I’ve been trying to accomplish this by using findall/3, but I can’t figure out a way to ask for the free variables and their possible values. If it helps, I’m using swiprolog.
Thanks.
Here is a solution to a similar problem. Instead of a list of answers represented as a list with entries
[V,term]for each variable, the querygoal_answers(Goal, Answerp)finds a pairVars-Terms.[Edit] To get the answers back in the original format use
library(lambda):