I had a peek on the cKanren branch, distincto is basically all-diffo in cKanren.
https://github.com/clojure/core.logic/blob/cKanren/src/main/clojure/clojure/core/logic.clj#L2229 Here's the port to core.logic. (change !=c to !=) (defn distincto [l] (conde [(== l ())] [(fresh [a] (== l [a]))] [(fresh [a ad dd] (== l (llist a ad dd)) (!= a ad) (distincto (llist a dd)) (distincto (llist ad dd)))])) (run* [q] (fresh [a b c] (membero a [1 2 3]) (membero c [1 2 3]) (== b 2) (distincto [a b c]) (== q [a b c]))) ;=> ([1 2 3] [3 2 1]) Pretty cool! Thanks, Ambrose On Sun, Jan 1, 2012 at 4:31 AM, cej38 <junkerme...@gmail.com> wrote: > I am trying to learn how to use core.logic. Here is a toy problem > that I am thinking about. > > (run* [q] > (fresh [a b c] > (membero a [1 2 3]) > (membero c [1 2 3]) > (== b 2) > (!= a b) > (!= a c) > (!= b c) > (== q [a b c]))) > > I would like to create a function that replaces the three != lines, > something like, (distincto [a b c]) such that I could rewrite the > above problem as > > (run* [q] > (fresh [a b c] > (membero a [1 2 3]) > (membero c [1 2 3]) > (== b 2) > (distincto [a b c]) > (== q [a b c]))) > > I tried to write several functions but they are all end up inside some > variant of a col, [(!= a b)(!= a c)(!= b c)]. Thus, I either need > someone to help me figure out how do write the distincto function, or > what to call on [(!= a b)(!= a c)(!= b c)] to get it to work. > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en