Skip to content

clojure.core/reduce-kv

View this page on ClojureDocs

Type: function Added: Clojure 1.4 Examples: 10 Runnable: 1
([f init coll])

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.

Examples

by viksit on . May have evaluation errors.
by Dimagog on . May have evaluation errors.
by Luckvery on . May have evaluation errors.
by puppybits on . May have evaluation errors.
by jvanderhyde on . May have evaluation errors.
by overset on . May have evaluation errors.
by bsifou on
by themustafabasit on . May have evaluation errors.
by cdol on . May have evaluation errors.
by cloudbuck3t on . May have evaluation errors.

Note by KingMob

Currently broken for subvectors: CLJ-2065

Note by diegonayalazo

Seems to be fixed for subvectors as of release 1.11. https://clojure.atlassian.net/browse/CLJ-2065

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.