Debian Codegraph @

tests/prob_prog/functions/1/rb-command.Rev

raw
1 function Integer[] cumsum(Integer[] xs) {
2 acc = 0
3 for (ix in 1:3) {
4 acc = acc + xs[ix]
5 ys[ix] = acc
6 }
7 return ys
8 }
9
10 for (ix in 1:3) {
11 z1[ix] = rpois(1, 1)
12 z2[ix] = ix
13 z3[ix] = 0
14 }
15
16 print(z1)
17 print(z2)
18 print(z3)
19
20 x = [1,2,3]
21
22 acc = 0
23 for (ix in 1:3) {
24 acc = acc + x[ix]
25 y1[ix] = acc
26 }
27 print(y1)
28
29 y2 = cumsum(x)
30 print(y2)