I'm looking into the clojure source code. The Implementation of PersistentArrayMap
has this conditional in the assoc
function:
if(array.length >= HASHTABLE_THRESHOLD)
return createHT(array).assoc(key, val);
Where HASHTABLE_THRESHOLD
is 16. So assoc should return a PersistentHashMap
if the arraymap already has 8 pairs. Now look at this clojure code:
(defn create [n, init] (if (= n 0) init (recur (dec n) (assoc init n n))))
(type (create 9 {}))
The output is clojure.lang.PersistentArrayMap
, shouldn't it be a PersistentHashMap
? Which is what I get if I use 10 instead of 9.