title: is there a function for partial sum?
body: <p>I want to do something like</p>
  
  <pre><code>foo = c(1, 1, 1)
  bar = magic_function(foo, sum, init=0)
  </code></pre>
  
  <p>where <code>bar</code> is <code>1 2 3</code>, i.e. the partial sum of <code>foo</code>. Is there such a function, or what is the best way of doing it (avoiding a for-loop)?</p>