Prolog 中的 +,+ 模式是什么意思? [英] What does +,+ mode in Prolog mean?
问题描述
所以我被告知一个特定的谓词必须在 +,+ 模式下工作.这在 Prolog 中是什么意思?
So am being told a specific predicate has to work in +,+ mode. What does that mean in Prolog?
推荐答案
当人们想在 prolog 中提供有关谓词的信息时,通常会使用这些约定:
When one wants to give information on a predicate in prolog, those conventions are often used :
arity : predicate/3 表示谓词有 3 个参数.
arity : predicate/3 means predicate takes 3 arguments.
parameters : predicate(+Element, +List, -Result) 意味着 Element 和 List 不应该是自由变量,Result 应该是一个自由变量,谓词才能正常工作.?当它可以同时使用时使用,@ 在上面的答案中提到但实际上并没有使用那么多(至少在 swi-pl 文档中)并且意味着在调用期间不会绑定输入.
parameters : predicate(+Element, +List, -Result) means that Element and List should not be free variables and that Result should be a free variable for the predicate to work properly. ? is used when it can be both, @ is mentionned on the above answer but is not really used as much (at least in swi-pl doc) and means that the input will not be bound during the call.
所以告诉 somepredicate 在 +, + 模式下工作是一个快捷方式:
so telling that somepredicate works in +, + mode is a shortcut for telling that :
% somepredicate/2 : somepredicate(+Input1, +Input2)
这篇关于Prolog 中的 +,+ 模式是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!