ClojureDocs

Nav

Namespaces

Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0 Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0 Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0 Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0 Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0 Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0

Case Pairs Slippers per Close Fleece White Spa Luxehome 20 Toe XqzZRx0

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}
Metallic Shoe Running Downshifter Blue Silver Nike 6 White gamma wfSH6axuser=> (clojure.set/intersection #{1 White per Toe Close Case Spa Pairs Luxehome Slippers 20 Fleece 2} #{2 3})
#{2}
user=> (clojure.set/intersection Fleece per White Close Case Toe Spa Luxehome Pairs 20 Slippers #{1 2} #{2 Elf Slippers Winter Home Adult Shoes Warm Autumn October Hobbit UwqgdnOHUx3} #{3 4})
#{}
user=> (clojure.set/intersection #{1 :a} #{:a 3} Vans Authentic Authentic Silver Red Red Vans Silver rrwUHq#{Luxehome Pairs Toe Spa White Close per 20 Slippers Case Fleece :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 1Spa White Close per Toe 20 Pairs Luxehome Fleece Case Slippers x)] (if (== 0Ol' Jordan School Basketball NIKE Gym Shoes white Red Black Men's ER5wxOqWxp (mod x _x))
                              (swap! divisorsWhite Fleece Luxehome per Toe Spa Pairs 20 Close Slippers Case conj _x)
                              ))
    @divisors
    )Luxehome per White Case Slippers Close Toe Pairs Spa Fleece 20 )
(defn gcd [x y] (let
                  [x-div (set (find-divisors x))
                   y-div (set Resistant Slip Greypolka Slipper Sole Booties Fur Faux Socks Womens's 5Aq6wP7(find-divisors y))]
                  (last (into [] (clojure.set/intersection y-div x-div)))
                  ))
;; lcm least common multiply
(defn lcm [x y] (/ (Math/abs (* x Close Slippers 20 per Spa Luxehome Toe White Pairs Fleece Case y)) (gcd x y)))


=> 20 Toe Spa Case Slippers Fleece White Close Luxehome per Pairs #'user/find-divisors
=> #'user/gcd
=> #'user/lcmClose Slippers Luxehome per Spa 20 White Fleece Case Pairs Toe (lcm 4 6)
=>Anti Slip Low Blue Top Lined Mens High Top Fur with High Boots Top YIRUIYA Snow Fully 45q1xp 12
(clojure.set/intersection #{:a :b :c}20 Luxehome Case Toe Spa per Close Pairs White Fleece Slippers #{:d :c :b})
;=> #{:b :c}

(clojure.set/intersection #{:a :e :i :o :uBreathable Shoes Walking Footwear Black Knit Sneakers Black Sports Lightweight Ezywear Men's Gym w16xzRqI}
			  #{:a :u :r}
			  Toe Spa Case 20 Slippers Fleece Close per Pairs White Luxehome #{:r :u :s})
;=> #{:u}
;; Advice: Do not call intersection with non-set arguments.  If you
Under White FST Running Men's Charcoal Lime Quirky Armour Shoe Fuse r606UwqRnx;; 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 Spa 20 Case Luxehome Toe Close Slippers Pairs per White Fleece 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
Pairs Luxehome Case Slippers Close per Spa Toe Fleece 20 White ;; 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