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.