ClojureCLR v2.5 Release Notes
-
reduce-kv
reduces an associative collection. It takes a functionf
, an initial valueinit
and an associative collectioncoll
.f
should be a function of 3 arguments. Returns the result of applyingf
toinit
, the first key and the first value incoll
, then applyingf
to that result and the 2nd key and value, etc. Ifcoll
contains no entries, returnsinit
👍 and f is not called. Note thatreduce-kv
is supported on vectors, where the keys will be the ordinals.(reduce-kv str "Hello " {:w \o :r \l :d \!}) ;=> "Hello :rl:d!:wo" (reduce-kv str "Hello " [\w \o \r \l \d \!]) ;=> "Hello 0w1o2r3l4d5!"