mini-kanren cond-a cond-u 和 cond-e 有什么区别?
我尝试在 clojure 中使用 mini-kanren 的实现。但一直在努力理解 cond-a cond-u 和 cond-e 之间的区别。我似乎对 cond-e 很清楚,但对 cond-a 和 cond-u 的理解却很糟糕。
cond-e 接受一组目标,然后尝试每个目标......即尝试所有成功的分支。
相反,cond-a 和 cond-u 提交第一个谓词成功的分支,并且 cond-a 返回此后所有可能的成功统一。虽然 cond-u 仅返回第一个成功的统一...但是,当我使用它时,这种理解似乎不正确。有人可以帮助我澄清这种理解吗?
I have tried to use an implementation of mini-kanren in clojure. But been struggling to understand the difference between cond-a cond-u and cond-e. I seem to be quite clear about cond-e but understanding of cond-a and cond-u is quiet bad.
cond-e takes a set of goals and then tries each of them... i.e tries all the branches that succeed.
cond-a and cond-u on the contrary commit to the branch whose first predicate succeeds and cond-a returns all the possible successful unifications there after. while cond-u returns only the first successfull unification ... but however it seems like this understanding is not correct when I use it. Can somebody help me clarify this understanding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cond-e 给出所有后续分支的每个答案
cond-i 给出每个答案,但将它们交错。
cond-a 仅给出第一个成功分支的答案
cond-u 仅给出第一个成功分支的第一个答案
cond-e gives every answer from all branches that succeed
cond-i gives every answer but interleaves them.
cond-a only gives the answers from the first successful branch
cond-u only gives the first answer from the first successful branch
我只是想弄清楚这些问题。有一个简化的方案实施
Sokuza-kanren 有一些评论,我今晚会读它。
I was just trying to get my head around these matters. There's a shortified scheme implementation
Sokuza-kanren with a few comments, I'll read it tonight.