Why does reduce-kv
on a priority-map call the reducing function with item as the key and priority as the value (source) instead of the map's key and value. Calling reduce
will be passed the map's key and value. I'm assuming it has something to do with this particular data structure's origins, but I cannot find any documentation pointing me to in in the clojure.data.priority-map ns. Here is an example.
(def m
(clojure.data.priority-map/priority-map-keyfn-by first compare
:a [2 :apples] :b [1 :bananas]))
(reduce-kv
(fn [acc k v]
(assoc acc k v))
{} m)
=> {:b 1, :a 2}
(reduce
(fn [acc [k v]]
(assoc acc k v))
{} m)
=> {:b [1 :bananas], :a [2 :apples]}
Is this the expected behavior? If so, could we add some documentation that this is how reduce-kv on a PersistentPriorityMap should work?