On Sun, 01 Nov 2009 09:20:21 +0900, Daniel Cohen wrote: > To Whom it May Concern: > > I have created a new patch for the Array Module of Ruby. The patch adds > two complementary features: A sum function, that sums the elements in an > array if they are numbers; and a mean (or average) function that finds > the mean of the elements in the the array using the sum function. > Attached is a patch to implement these features. I apologize in advance > if this has already been proposed. > > Sincerely, > Daniel Cohen > To Whom it May Concern:<br><br>I have created a new patch for the Array > Module of Ruby. The patch adds two complementary features: A sum > function, that sums the elements in an array if they are numbers; and a > mean (or average) function that finds the mean of the elements in the > the array using the sum function. Attached is a patch to implement these > features. I apologize in advance if this has already been proposed.<br> > <br>Sincerely,<br>Daniel Cohen<br> Shouldn't the sum of integers return an integer? Converting everything to double when there are no doubles in the array can cause a loss of precision, and is definitely surprising to the user who doesn't expect this. -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/