Oops, you already said that, my bad. :) -- Science answers questions; philosophy questions answers.
On Jul 21, 2010, at 8:13 PM, Frederick Polgardy wrote: > Or [using clojure.set] (empty? (intersection s1 s2)). > > -- > Science answers questions; philosophy questions answers. > > On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote: > >> The second function is suggested as an addition to clojure.set. The >> "disjoint?" function decides if two sets have no elements in common. >> This can easily be done using: >> >> (not (nil? (intersection s1 s2))) >> >> but this implementation should be more efficient (I think) and is more >> readable, imho: >> >> (defn disjoint? >> "Is set1 disjoint from set2?" >> {:added "1.3" :tag Boolean} >> [set1 set2] >> (if (<= (count set1) (count set2)) >> (recur set2 set1) >> (not-any? (fn [item] (contains? item set1)) set2))) > -- 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