mini-kanren what is the difference between cond-a cond-u and cond-e?

余生颓废 提交于 2019-12-01 05:54:40

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/4112996/mini-kanren-what-is-the-difference-between-cond-a-cond-u-and-cond-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!