gpt4 book ai didi

prolog - Prolog 中的奇怪运算符 (!)

转载 作者:行者123 更新时间:2023-12-04 17:27:32 27 4
gpt4 key购买 nike

hi(g,plus(A,B),int) :- hi(g,A,int),hi(g,B,int),!.  

在上面的语句中 '!' 是什么意思?在声明的末尾签名吗?

最佳答案

那是 cut operator ,基本上是说“如果我们到了这里,就不要回头。”

所以,如果两个递归调用都成功,hi谓词不会重试它们。

关于prolog - Prolog 中的奇怪运算符 (!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5895819/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com