I’m looking for a very similar function that satisfies length(accumulate(op, input; [init])) == length(input) + 1
and isequal(last(accumulate′\prime(args...;kwargs...)), reduce(args...;kwargs...))
The last property is satisfied for accumulate, except for empty inputs.
Is there a cleaner way to get that behavior with existing primitives? It would be cool if there were some composable way to get this behavior, so that e.g. last(cumsum′(Int[])) == sum(Int[])
Thanks! I’ve been meaning to learn about Transducers.jl.
I think it would be great if there were a way to get this behavior without needing to define a helper, and optionally mentioning init just once, using the ontology of InitialValues.jl.
Does something like that fit into the transducers model? Would something like append!!(ScanInit(+, -10), [], [1,2,3]) be possible?