From: "David A. Black" Date: 2009-07-22T08:03:34+09:00 Subject: Re: Standard Deviation question regarding EDOM errors --1926193751-135177676-1248217340=:23297 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-135177676-1248217340=:23297" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-135177676-1248217340=:23297 Content-Type: TEXT/PLAIN; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Wed, 22 Jul 2009, Älphä Blüë wrote: > Hi David, > > I think I understand what you are saying.. > > What I want with.. > > product += a*a > > > is .. a[0]*a[0]+a[1]*a[1]+a[2]*a[2]..etc. OK, then the product method in the class is wrong. "Product" doesn't sound like the right name for a sum-of-the-squares calculation. But anyway -- def whatever_you_call_it # :-) @arr.inject(0) {|acc,x| acc + x * x } end David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN) --1926193751-135177676-1248217340=:23297-- --1926193751-135177676-1248217340=:23297--