I have most Compound Term, such as:
likes(a, b).
likes(c, b).
likes(a, d).
likes(b, c).
likes(c, a).
likes(a, f).
go(a, t).
go(t, d).
go(g, a).
go(f, g).
go(f, a).
I want to search Compound Tern, value of Atom is "a", value of the other Atom is any value.
The result of Prolog return:
likes(a, b).
likes(a, d).
likes(c, a).
likes(a, f).
go(a, t).
go(g, a).
go(f, a).
Please, help me
I've written here a generic helper. I thought that less builtins were needed...
Phew...
test:
edit: after @false' suggestion, the code could be simplified
here is the functor/3 documentation. The essential builtin is clause/2, here another simplified way, using univ to build the 'template' head:
First you need to "reify" the predicate term. Your theory becomes:
Add the following:
And you're done.
You could use meta-predicates like =.. to avoid changing your theory. Personally I think that's the wrong approach. Better to have the right formalisation of the problem from the start.