Search code examples
clojureprologthe-little-schemerminikanren

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


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.


Solution

  • 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