JuliaData / SplitApplyCombine.jl

Split-apply-combine strategies for Julia
Other
149 stars 15 forks source link

Support transducers? #27

Open tkf opened 4 years ago

tkf commented 4 years ago

Is there any chance you can support transducers in groupreduce? Roughly speaking it's "just" rewriting

acc = init
for x in xs
    acc = op(acc, x)
end

to

acc = start(op, init)
for x in xs
    acc = next(op, acc, x)
    acc isa Reduced && return acc  # required only for terminatable transducers
end
acc = complete(op, acc)

This way, I can pass op = reducingfunction(transducer, original_op) to groupreduce. It is useful for complex per-group operations fused with the reduction. I can split the abstract interface in a separate package if requiring whole Transducers.jl is not ideal.