Fork me on GitHub

Transducers to bucket a sequence by some accumulate function and test condition of the accumulated result. Also another one to emit the current bucket on each new input. Any thoughts? I think I still have to figure out the transducer edge cases (like checking for reduced?)


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