On Wed, 11 Mar 2009 21:51:51 -0700 (PDT) Raffael Cavallaro <raffaelcavall...@gmail.com> wrote: > On Mar 11, 11:43 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote: > > > Here are the expressions and results in a simplified notation: > > > > #{a b c} - #{a b} => #{c} > > > > #{a b} - #{a b c} => #{} > > ok, so I was misunderstanding how difference works. I thought both > would evaluate to #{c}. > > thanks
clojure.set/difference implements the "relative complement" operation. I don't see a "symmetric difference" operation in clojure.set, but it might be useful: (defn symmetric-diff [xset yset] (difference (union xset yset) (intersection xset yset))) It can also be implemented as the union of both relative complements: (defn symmetric-diff [xset yset] (union (difference xset yset) (difference yset xset))) If you'd like to add it to the set library, I hereby release both versions into the public domain. Also, union/difference/intersection/symmetric-diff are binary. Would there be any interest in a patch to make them n-ary? -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---