hopefully it's not too late for feedback:
• the transducers in clojure.core use volatile!
or ArrayList
for state. see partition-all
• the transducers that accumulate state (like partition-all
implement the completion arity to flush the state at the end. in your examples, it looks like the last bucket doesn't make it to the output
personally, I would probably implement bucket
as a composition of partition-by
and map
.
Never too late for feedback 🙂
Yeah I'm aware of the arraylist/volitile thing. I assume those are mainly performance optimizations that I haven't need yet but would probably switch to at some point.
The thing that makes partition-by
insufficient is that the parts require accumulating state rather than just checking the single input. for example if I have a stream of integers and want to break them into partitions where the sum of each partition is 10.
ohhh, that makes sense