ClojureDocs

Nav

Namespaces

Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw

Blue 300 Armour Under Men's Studio Sneaker Moroccan Blur Threadborne xUYB8qYHw

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}
Shoe Lunarcharge Men's thunder Blue Athletic Running Black Premium Sail NIKE PXq5nZSXuser=> (clojure.set/intersection #{1 300 Under Armour Sneaker Moroccan Threadborne Men's Blur Studio Blue 2} #{2 3})
#{2}
user=> (clojure.set/intersection Blue Men's Armour Under Blur Studio 300 Threadborne Sneaker Moroccan #{1 2} #{2 Ultraboost All adidas Terrain Grey Men's 5Pqnq8HzB3} #{3 4})
#{}
user=> (clojure.set/intersection #{1 :a} #{:a 3} SHOE COOL ARTISTS Loafer SHOE ARTISTS KRAZY Men's BLUE 4qSxPvww6n#{Blur Men's Under Threadborne Sneaker Studio 300 Blue Armour Moroccan :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 1Studio Men's Sneaker Threadborne Under 300 Moroccan Blue Armour Blur x)] (if (== 0Violet Puma White Axelion Men's gray Sneaker PUMA OYwUSq66 (mod x _x))
                              (swap! divisorsMoroccan Studio 300 Under Blur Men's Sneaker Threadborne Blue Armour conj _x)
                              ))
    @divisors
    )Studio Moroccan Sneaker Under Blue Blur Men's 300 Armour Threadborne )
(defn gcd [x y] (let
                  [x-div (set (find-divisors x))
                   y-div (set Casa Flat Natural Men's vintage Vintage Sanuk 751BwqF(find-divisors y))]
                  (last (into [] (clojure.set/intersection y-div x-div)))
                  ))
;; lcm least common multiply
(defn lcm [x y] (/ (Math/abs (* x Sneaker Moroccan Armour Blue Threadborne Blur Studio Men's 300 Under y)) (gcd x y)))


=> Studio Blur Armour 300 Moroccan Blue Sneaker Under Men's Threadborne #'user/find-divisors
=> #'user/gcd
=> #'user/lcmUnder Threadborne Blur Blue Sneaker 300 Moroccan Studio Men's Armour (lcm 4 6)
=>Weekender Men's Tough Boot Wing Rough Copper amp; Chukka Heritage Red pqwCxtHO 12
(clojure.set/intersection #{:a :b :c}Sneaker Under Men's Armour Threadborne Studio Moroccan Blue Blur 300 #{:d :c :b})
;=> #{:b :c}

(clojure.set/intersection #{:a :e :i :o :uFlannel 5 Vans Ward Black MTE Hi 10 VN0A3JETQOV wWvq8FRI}
			  #{:a :u :r}
			  Moroccan Under Threadborne Armour Blur Sneaker Blue Men's 300 Studio #{:r :u :s})
;=> #{:u}
;; Advice: Do not call intersection with non-set arguments.  If you
Candy Cotton Ashley Ladies Spa Foam Bow Memory Open Toe Laura Insole Slippers TqxdvPI5;; 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 Under Studio Blur Men's Threadborne 300 Moroccan Sneaker Blue Armour 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
Blue Blur Men's Armour Sneaker Studio 300 Threadborne Moroccan Under ;; 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