rebellion
rebellion copied to clipboard
Grouping, but with a transducer instead of a reducer
Half-baked idea: an entry?
transducer constructor named partitioning
that's like grouping
, but instead of combining the values for each key using a reducer, it transduces the values for each key using another transducer. Example:
> (transduce (in-hash-entries (hash 'foo "hello" 'bar "world"))
(partitioning (taking 3))
#:into into-multidict)
(multidict
'foo #\h
'foo #\e
'foo #\l
'bar #\w
'bar #\o
'bar #\r)
Given a function to turn a reducer into a transducer that only performs the reduction once, grouping
becomes a special case of partitioning
.
This seems kind of like #347 in disguise. It probably has the same issues related to transducers that insert stuff at the beginning and end of the stream.