<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged data.int-map</title>
<link>https://ask.clojure.org/index.php/tag/data.int-map</link>
<description></description>
<item>
<title>int-map: difference ignores its second argument when the first is itself a difference result</title>
<link>https://ask.clojure.org/index.php/15241/difference-ignores-second-argument-itself-difference-result</link>
<description>&lt;pre&gt;&lt;code&gt;(require '[clojure.data.int-map :as i])

(-&amp;gt; (i/int-set [10 1000297])
      (i/difference (i/int-set [10]))        ;=&amp;gt; #{1000297}
      (i/difference (i/int-set [1000297])))  ;=&amp;gt; #{1000297}, expected #{}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When SingleContainer/difference removes its only element, it returns null.  IntSet/difference puts that null into the tree instead of dropping the key. In the next difference, the entry with the null value goes to the else branch, which is meant for k1 &amp;gt; k2. That branch moves i2 forward without comparing anything, so the rest of the first set gets copied as is.&lt;/p&gt;
&lt;p&gt;Skipping null values from the first set in that loop should fix it. So should not storing empty results in the first place. :)&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15241/difference-ignores-second-argument-itself-difference-result</guid>
<pubDate>Fri, 02 Oct 2026 11:28:00 +0000</pubDate>
</item>
</channel>
</rss>