问题
Reading the SWI-Prolog documentation on meta-predicates, I initially assumed that call(f, ...) is equivalent to f(...), where f is some predicate. But I observe that the behavior of the two actually diverge in certain cases. For instance, suppose a knowledge base includes the clause f(g(x)). Then the query call(f, g(x)) succeeds, whereas f(call(g, x)) does not. This is problematic, because I sometimes need to use clauses whose bodies include nested predicate calls. I'd like Prolog to evaluate all predicate calls eagerly (I wonder if this is the right word?), such that the query f(call(g, x)) reduces to f(g(x)) before unification begins, and succeeds. Is this possible?
来源:https://stackoverflow.com/questions/40443755/eagerly-evaluating-all-predicate-calls-in-prolog