partial-sums ( seq -- seq' )


Vocabulary
math.extras.private

Inputs
seqan object


Outputs
seq'an object


Definition


:: partial-sums ( seq -- seq' )
V{ } clone :> partials seq [
0 partials [
swapd sort-partial partial+ swapd
[ over partials set-nth 1 + ] unless-zero
] each :> i i partials shorten
[ i partials set-nth ] unless-zero
] each partials ;