reduce-kv

functionsince v0.0-1211 clojure.core/reduce-kvEdit
(reduce-kv f init coll)

Details:

Reduces an associative collection.

f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc.

If coll contains no entries, returns init and f is not called.

Note that reduce-kv is supported on vectors, where the keys will be the ordinals.


See Also:


Source docstring:
Reduces an associative collection. f should be a function of 3
arguments. Returns the result of applying f to init, the first key
and the first value in coll, then applying f to that result and the
2nd key and value, etc. If coll contains no entries, returns init
and f is not called. Note that reduce-kv is supported on vectors,
where the keys will be the ordinals.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn reduce-kv
  ([f init coll]
    (if (satisfies? IKVReduce coll)
      (-kv-reduce coll f init)
      (reduce (fn [ret me]
                (f ret (-key me) (-val me)))
        init coll))))