A hash collision occurs when distinct keys produce the same hash value or hash-table index. Hashing quality matters because frequent collisions can make composite-key maps inefficient. section 6.6
Java hashCode can create easy collisions for values such as longs, vectors, or sets. Clojure’s hash function accounts for these cases, reducing frequent collisions for numbers and small collections used as keys. section 6.6
Composite keys with colliding Java hashes
Several long values produce repeated Java hashCode results: (-3 -2 -1 0 1 2) becomes (2 1 0 0 1 2). Two distinct composite sets both produce 2274. Applying Clojure’s hash instead produces distinct results for the sets: (2055406432 -916052234).
When working with keys and hashing:
- Prefer Clojure hashing for Clojure collections used as map keys when frequent Java hashCode collisions would be a concern. section 6.6



