6.3.26 Cumulated sum of the elements of a list
The
cumSum
command finds the partial sums of a list or sequence.
cumSum
takes
L
, a list or sequence of numbers or of strings.
cumSum(
L
)
returns the list or sequence with same length as
L
and whose
k
th element is the sum or concatenation of elements 0 through
k
of
L
.
Examples
cumSum
(
sqrt
(2),3,4,5,6)
√
2
,
√
2
+3,
√
2
+3+4,
√
2
+3+4+5,
√
2
+3+4+5+6
normal
(
cumSum
(
sqrt
(2),3,4,5,6))
√
2
,
√
2
+3,
√
2
+7,
√
2
+12,
√
2
+18
cumSum
(1.2,3,4.5,6)
1.2,4.2,8.7,14.7
cumSum
([0,1,2,3,4])
⎡
⎣
0,1,3,6,10
⎤
⎦
cumSum
(
"a"
,
"b"
,
"c"
,
"d"
)
“a”
,
“ab”
,
“abc”
,
“abcd”
cumSum
([
"a"
,
"ab"
,
"abc"
,
"abcd"
])
⎡
⎣
“a”
,
“aab”
,
“aababc”
,
“aababcabcd”
⎤
⎦