I have a few thousand rows of stock market data - one row for each

day. I'm using ActiveRecord to perform database operations.

I'm interested in performing a calculation on each row while

incorporating the result of the calculation on the previous row, and

then once the calculation has been performed for all rows, perform a

new calculation that uses the individual calculations of each row.

I figure that I'll start with an array of size 3,000. Then I would

probably want to iterate over it, possibly saving the result of the

operation of each row to a new array but this area is a little foggy.

Any suggestions?