You're viewing version 1.2.0 of union. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

union

clojure.set

  • (union)
  • (union s1)
  • (union s1 s2)
  • (union s1 s2 & sets)
Return a set that is the union of the input sets

1 Example top

  • user=> (union)
    #{}
    user=> (union #{1 2})
    #{1 2}
    user=> (union #{1 2} #{2 3})
    #{1 2 3}
    user=> (union #{1 2} #{2 3} #{3 4})
    #{1 2 3 4}
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/set.clj:19 top

(defn union
  "Return a set that is the union of the input sets"
  {:added "1.0"}
  ([] #{})
  ([s1] s1)
  ([s1 s2]
     (if (< (count s1) (count s2))
       (reduce conj s2 s1)
       (reduce conj s1 s2)))
  ([s1 s2 & sets]
     (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
       (reduce into (first bubbled-sets) (rest bubbled-sets)))))
Vars in clojure.set/union: < conj count defn first into let reduce rest
Used in 0 other vars

Comments top

No comments for union. Log in to add a comment.