title: generalized cumulative functions in NumPy/SciPy?
body: <p>Is there a function in numpy or scipy (or some other library) that generalizes the idea of cumsum and cumprod to arbitrary function. For example, consider the (theoretical) function</p>
  
  <pre><code>cumf( func, array) 
  </code></pre>
  
  <p>func is a function that accepts two floats, and returns a float. Particular cases </p>
  
  <pre><code>lambda x,y: x+y 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>lambda x,y: x*y 
  </code></pre>
  
  <p>are cumsum and cumprod respectively. For example, if </p>
  
  <pre><code>func = lambda x,prev_x: x^2*prev_x 
  </code></pre>
  
  <p>and I apply it to:</p>
  
  <pre><code>cumf(func, np.array( 1, 2, 3) )
  </code></pre>
  
  <p>I would like </p>
  
  <pre><code>np.array( 1, 4, 9*4 )
  </code></pre>