From: Robert Dober Date: 2006-09-04T00:22:24+09:00 Subject: Re: Happy Numbers (#93) ------=_Part_107742_21796522.1157296896933 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/3/06, Phrogz wrote: > > Sander Land wrote: > > class Array > > def sum > > inject(0){|a,b| a+b} > > end > > end > > For a little more speed, try instead: > > class Array > def sum > inject{ |a,b| a+b } > end > end > > > The following is about three times faster on my box (there was a recent thread about it, was there not ;) class Array def sum s=3D0 each{ | e | s+=3D e } s end end Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_107742_21796522.1157296896933--