Harry Kakueki wrote in post #1012785: >> >> for i in 1...arr.length >> arr[i] += arr[i - 1] >> end >> > > If you make a new array you could try something like this. > I do not know how fast it is but if you only have about 12 elements..... > > p Array.new(arr.size){|x| arr[0..x].inject{|a,b| a+b}} > > > > > > > Harry Tx for all the nice ideas! I agree that with an array this size speed doesn't really matter except that it somehow figures into good programming style--along with making good use of the specific features and conventions of whatever language you are using. -- Posted via http://www.ruby-forum.com/.