From: Victor Reyes Date: 2008-05-24T02:13:05+09:00 Subject: Re: Is rdoc (http://www.ruby-doc.org/core/) complete? ------=_Part_18433_18183192.1211562691010 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The beauty of Ruby! Many and elegant ways to solve a problem! Thanks guys! Victor On Thu, May 22, 2008 at 10:21 PM, Pe=F1a, Botp wro= te: > From: Victor Reyes [mailto:victor.reyes@gmail.com] > #thank you for the code snippet. > > also try ruby1.8.7 or ruby1.9 > > 036:0> a > =3D> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9= ] > > 037:0> a.group_by{|k| k }.inject({}){|h,(k,v)| h[k] =3D v.size; h } > =3D> {1=3D>2, 2=3D>3, 3=3D>4, 4=3D>4, 5=3D>3, 6=3D>2, 7=3D>2, 8=3D>2, 9= =3D>1} > > ------=_Part_18433_18183192.1211562691010--