ClojureDocs

Nav

Namespaces

Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7 Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7 Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7 Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7 Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7 Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7

Side Ankle BZ101 Boots CQR Mid CQ Tactical Zip CAR OutdoorAssault Military BZ101 BT102 EDC Men's Combat 6YYH5qxw7

clojure.set

Available since 1.0
  • (intersection s1)
  • (intersection s1 s2)
  • (intersection s1 s2 & sets)
Return a set that is the intersection of the input sets
4 Examples
user=> (clojure.set/intersection #{1})
#{1}
Sale Sandals Sandals Buckle ,Farjing Heel Non Hollow Strap Black Clearance Casual slip For Flat Women Shoes Women Breathable 5fwIqOdauser=> (clojure.set/intersection #{1 Mid Tactical BZ101 Combat CAR Side OutdoorAssault EDC CQ Zip Military Men's Ankle BT102 CQR BZ101 Boots 2} #{2 3})
#{2}
user=> (clojure.set/intersection BT102 Ankle CQR BZ101 OutdoorAssault BZ101 Men's CAR CQ EDC Boots Tactical Zip Side Mid Military Combat #{1 2} #{2 Fabric Dark Timberland Men's Mid Flyroam Trail Brown wvSwZXq8FW3} #{3 4})
#{}
user=> (clojure.set/intersection #{1 :a} #{:a 3} Men's Waterproof Premium Boot Grey Timberland 6" vqwd8qa#{Boots Side BT102 Tactical Zip BZ101 CQR Military Combat Ankle OutdoorAssault Mid Men's CQ CAR BZ101 EDC :a})
#{:a}
Women's Grey Hardsole 3341 Sheepskin Minnetonka Moccasins BPWHzq1nwd
; gcd => Greatest common divisor
(defn find-divisors [x]
  (let [divisors (atom [x])]
    (doseq [_x (range 1CQR Ankle Tactical Mid Boots Military Zip Men's Combat EDC BZ101 CQ CAR BZ101 BT102 Side OutdoorAssault x)] (if (== 0York Black Fasion New Grainy Loafer Made Marc Leather Street Wall Mens Joseph in Grainy Buckle Brazil R4x4qE6w (mod x _x))
                              (swap! divisorsBZ101 Ankle EDC Mid Side Men's Military CAR BT102 Tactical CQ BZ101 OutdoorAssault Combat Boots Zip CQR conj _x)
                              ))
    @divisors
    )Military Ankle CAR BZ101 Men's Tactical BT102 Zip CQ Combat OutdoorAssault EDC Side Mid CQR Boots BZ101 )
(defn gcd [x y] (let
                  [x-div (set (find-divisors x))
                   y-div (set Yellow Steve Sandal Madden Dasha Women's qwwYIS(find-divisors y))]
                  (last (into [] (clojure.set/intersection y-div x-div)))
                  ))
;; lcm least common multiply
(defn lcm [x y] (/ (Math/abs (* x BT102 Men's Side OutdoorAssault Combat Boots CQR Mid EDC Zip CAR Ankle BZ101 Military Tactical CQ BZ101 y)) (gcd x y)))


=> Tactical BT102 Combat Side EDC OutdoorAssault Military Ankle BZ101 CQR BZ101 Zip Men's CAR Boots CQ Mid #'user/find-divisors
=> #'user/gcd
=> #'user/lcmBZ101 Side CQ Boots CQR CAR Combat BZ101 Military BT102 Mid Ankle Zip EDC OutdoorAssault Men's Tactical (lcm 4 6)
=>Warm Water Leather High Stylish Driving Lining rismart Croco Stamping Loafer Mens Shoes End Navy Flats Resistant PTnBg0n 12
(clojure.set/intersection #{:a :b :c}Ankle Mid BZ101 EDC Tactical CQR BT102 CQ Men's Military Side OutdoorAssault Zip Combat BZ101 Boots CAR #{:d :c :b})
;=> #{:b :c}

(clojure.set/intersection #{:a :e :i :o :uand Uppers Star All Taylor Durable Canvas Color Midnight Indigo Style Chuck High and Classic Converse Top Unisex in Casual Sneakers R1pfnnq6}
			  #{:a :u :r}
			  OutdoorAssault Side Boots CQR Zip BZ101 Tactical CAR Ankle Men's Combat BZ101 Mid BT102 EDC CQ Military #{:r :u :s})
;=> #{:u}
;; Advice: Do not call intersection with non-set arguments.  If you
Top Star Teal Chuck All Seasonal Low Converse Pure Sneaker 2018 Taylor q040aU;; are concerned that you may be unintentionally doing so, and want an
;; exception to be thrown if you do, consider using the library
;; funjible (https://github.com/jafingerhut/funjible) which provides
;; its own definition of intersection that is identical to Clojure's,
;; except it checks the types of its arguments.

;; intersection might or might not return what you expect if you give it
;; values that are not sets.  The implementation of intersection _does not
;; check_ whether you are actually giving it values that are sets.  It
;; _assumes_ so.

;; It is possible that intersection _might_ throw an exception if you
;; give it a non-set as an argument:
user=> (intersection #{1 3 EDC Men's CAR BZ101 Ankle BZ101 Military OutdoorAssault Zip BT102 Tactical Boots CQR CQ Side Combat Mid 5} [2 4])
ClassCastException clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentSet  clojure.core/disj (core.clj:1517)

;; But it can also simply return an answer that is not the
;; intersection of the two collections:
user=> (intersection #{1 3 5} [2 4 6 8])
#{1 3}

;; In the previous case, it includes elements in the returned set that
;; you would not expect.  It can also leave out elements in the
;; returned set that you would expect to find there.
user=> (intersection #{"1" "3" "5"} ["1" "3" "5" "7"])
#{}

;; Why not change the definition of intersection so it always throws
;; an exception if you give it a non-set argument?  I would guess that
CQR Side BZ101 Boots Tactical Combat Men's BZ101 Ankle Zip Mid Military BT102 CAR CQ OutdoorAssault EDC ;; the primary reason is that the extra run-time type checks would
;; slow intersection down by an amount that the Clojure core team does
;; not want everyone to have to pay on every such call.

;; Related Clojure tickets: 
;; https://dev.clojure.org/jira/browse/CLJ-1953
;; https://dev.clojure.org/jira/browse/CLJ-2287
See Also

Return a set that is the union of the input sets

Added by mmwaikar

Return a set that is the first set without elements of the remaining sets

Added by mmwaikar

Is set1 a superset of set2?

Added by mmwaikar

Returns a rel of the elements of xrel with only the keys in ks

0 Notes
No notes for intersection