Handbook
Glossary
cum-sum ( seq -- seq' )
Statistics
ยป
Computing cumulative sequences
Next:
cum-sum0 ( seq -- seq' )
Vocabulary
math
.
statistics
Inputs
seq
a
sequence
Outputs
seq'
a
sequence
Word description
Returns the cumulative sum of
seq
.
Examples
USING: math.statistics prettyprint ; { 1 -1 2 -1 4 } cum-sum .
{ 1 0 2 1 5 }
Definition
USING:
math
sequences
;
IN:
math.statistics
:
cum-sum
( seq -- seq' )
0
[
+
]
accumulate*
;