Let's say I've declared predicates a and c as follows:
a(b).
c(D, E) :- D(E).
I'd like to believe that c(a, b) succeeds, as D(E) matches a(b) if D is bound to a and E is bound to b, but (in SWI Prolog anyway) syntax checking is looking for an operator following D in the definition of c, so apparently there's a rule that unification binds variables only to arguments, not functors. Is there some trick for asking the question posed by c, in which the identity of a predicate is one of the unknowns?
You can make use of call/2 predicate [swi-doc]
to call a predicate with the given name and parameters. So your c/2 predicate is equivalent to call/2:
c(D, E) :-
call(D, E).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With