While reviewing a recent pull request in
Images.jl, I ran across this line:
cum_pmf_sq_2 = reverse!(cumsum(reverse!(prob_mass_function_sq)))
reverse! is better than
reverse here, but writing out the loops manually would certainly be more efficient. I’m wondering if it’s worthwhile to try to add some conveniences for this:
- Add a
- Add a
ReverseViewwrapper to a
Vector, which reverses the indexes (and therefore iteration), but otherwise leaves the data alone.
@stevengj recently added
Iterators.Reverse, but that doesn’t work here, as
cumsum (which is based on
accumulate) requires an
Iterators.Reverse isn’t one of those.
I can, of course, make these additions in a package, but they seem general enough that perhaps they could be included in Base. Thoughts?