mini-kanren cond-a cond-u 和 cond-e 有什么区别? [英] mini-kanren what is the difference between cond-a cond-u and cond-e?

查看:34
本文介绍了mini-kanren cond-a cond-u 和 cond-e 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 clojure 中使用 mini-kanren 的实现.但是一直在努力理解 cond-a cond-u 和 cond-e 之间的区别.我似乎对 cond-e 很清楚,但对 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 设定一组目标,然后尝试每个目标……即尝试所有成功的分支.

cond-e takes a set of goals and then tries each of them... i.e tries all the branches that succeed.

相反,cond-a 和 cond-u 提交到第一个谓词成功的分支,并且 cond-a 在那里返回所有可能的成功统一.虽然 cond-u 只返回第一个成功的统一......但是当我使用它时,这种理解似乎是不正确的.有人能帮我澄清一下这个理解吗.

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.

推荐答案

cond-e 给出所有成功分支的所有答案

cond-e gives every answer from all branches that succeed

cond-i 给出每个答案,但将它们交错.

cond-i gives every answer but interleaves them.

cond-a 只给出第一个成功分支的答案

cond-a only gives the answers from the first successful branch

cond-u 只给出第一个成功分支的第一个答案

cond-u only gives the first answer from the first successful branch

这篇关于mini-kanren cond-a cond-u 和 cond-e 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆