Welcome! Please see the About page for a little more info on how this works.

0 votes
in data.int-map by

This is for org.clojure/data.int-map v 1.0.0.
At the same time clojure.set/intersection and clojure.set/union handle the case well.

(ns sandbox
  (:require
   [clojure.data.int-map :as int-map]
   [clojure.set]))

(clojure.set/intersection #{1 3} #{1 2 3}) ; => #{1 3}
(clojure.set/intersection #{1 3} nil) ; => nil
(clojure.set/intersection nil #{1 2 3}) ; => nil

(int-map/intersection (int-map/int-set #{1 3}) (int-map/int-set #{1 2 3})) ; => #{1 3}
(int-map/intersection (int-map/int-set #{1 3}) nil) ; => NullPointerException
(int-map/intersection nil (int-map/int-set #{1 2 3})) ; => NullPointerException

(clojure.set/union #{1 3} #{2}) ; => #{1 3 2}
(clojure.set/union #{1 3} nil) ; => #{1 3}
(clojure.set/union nil #{2}) ; => #{2}

(int-map/union (int-map/int-set #{1 3}) (int-map/int-set #{2})) ; => #{1 2 3}
(int-map/union (int-map/int-set #{1 3}) nil) ; => NullPointerException
(int-map/union nil (int-map/int-set #{2})) ; => NullPointerException

Please log in or register to answer this question.

...