mini-kanren cond-a cond-u 和 cond-e 有什么区别?

发布于 2024-09-30 17:41:40 字数 294 浏览 5 评论 0原文

我尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡少年 2024-10-07 17:41:40

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

丢了幸福的猪 2024-10-07 17:41:40

我只是想弄清楚这些问题。有一个简化的方案实施
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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文