Just noticed that accumulate does not include its init
value in the output vector. What is the reason for that choice?
Including init would be handy for cases like:
v = rand(10)
accumulate(+, diff(v); init = v[1])
It would also match scanl
in Haskell. There it’s motivated as scanl f e = map (foldl f e) . inits
where inits
computes all prefixes (starting with the empty one).