Question: Record a running total based upon a changing variable?

I'm hoping that someone can help with this.  Below is an example of what I would like to do (part of a larger application):

> roll := rand(0 .. 1);

> roll();> s0 := %;                              

> roll();> s1 := %;                

With each execution, this will yield values for s0 and s1 that are randomly chosen to be either 0 or 1.  What I would like to do is to accumulate a running total of these values, such that with each execution, there is a "cumulative s0" and "cumulative s1" that results- i.e., it needs to store the previous values, add the new value to the total, etc..   I realize that in this trivial example the result will be equal in both groups over time, but it's the principle that I'm interested in.

Is it possible to do this sort of thing in Maple?  I suspect that it might require a programming loop of some sort, but I'm still learning these things and would appreciate being pointed in the right direction.

Thanks for any help.

Steve          

Please Wait...