Eagerly evaluating all predicate calls in Prolog

﹥>﹥吖頭↗ 提交于 2019-12-24 02:55:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!