mini-kanren what is the difference between cond-a

2020-03-24 08:01发布

问题:

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.