function | since v0.0-927 | clojure.set/difference | Edit |
(difference s1)
(difference s1 s2)
(difference s1 s2 & sets)
Return a set that is the first set without elements of the remaining sets.
Return a set that is the first set without elements of the remaining sets
(defn difference
([s1] s1)
([s1 s2]
(if (< (count s1) (count s2))
(reduce (fn [result item]
(if (contains? s2 item)
(disj result item)
result))
s1 s1)
(reduce disj s1 s2)))
([s1 s2 & sets]
(reduce difference s1 (conj sets s2))))