clojure.set/intersection

functionsince v0.0-927 clojure.set/intersectionEdit
(intersection s1)
(intersection s1 s2)
(intersection s1 s2 & sets)

Details:

Return a set that is the intersection of the input sets.


See Also:


Source docstring:
Return a set that is the intersection of the input sets
Source code @ clojurescript:src/main/cljs/clojure/set.cljs
(defn intersection
  ([s1] s1)
  ([s1 s2]
     (if (< (count s2) (count s1))
       (recur s2 s1)
       (reduce (fn [result item]
                   (if (contains? s2 item)
		     result
                     (disj result item)))
	       s1 s1)))
  ([s1 s2 & sets] 
     (let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]
       (reduce intersection (first bubbled-sets) (rest bubbled-sets)))))