IKVReduce is the protocol behind reduce-kv, specializing reduction for associative data structures by passing a reducing function the accumulator, key, and value. section 11.3.4
A reducing function receives three arguments: the current result, a key, and its value. The initial value seeds the first call, and the final accumulated result is returned. section 11.3.4
The protocol determines which collections can use the specialized path:
- Unsupported types, including ordinary Java maps without an extension, throw IllegalArgumentException. section 11.3.4
Extending Java maps
extend-protocol can implement IKVReduce for java.util.Map by iterating entries and invoking the reducing function. The resulting reduce-kv call can transform System/getenv into keyword keys.
