From: "Shot (Piotr Szotkowski)" Date: 2007-12-16T08:03:20+09:00 Subject: An idiomatic way to traverse all pairs in an enumerable? --wg9FEZT+WCTrEXgJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I seem to end up doing the following quite a lot: enum.each do |a| enum.each do |b| next if a >=3D b # do_something with a and b end end In general, I=E2=80=99m looking for an idiomatic way of traversing each possible pair of a given enum=E2=80=99s contents (once). Is there a more compact construct? (I assume I could finally grasp the whole block-passing side of Ruby and write my own Enumerable#each_mix, but maybe there=E2=80=99s something t= here already. Note: Enumerable#each_pair doesn=E2=80=99t cut it, as it=E2=80=99s= just for neighbouring element pairs, while I need something for all possible pairs.) Thanks in advance for any help with the above! -- Shot --=20 The existential root of libertarianism is the experience of being very bad at taking orders from morons. -- Leopold Leider --wg9FEZT+WCTrEXgJ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFHZFa4i/mCfdEo8UoRAgRLAJ4wR/t8Gty7zL+KymhoKRtlVqGKAACfUuD/ NL5tdGJTAUwcN9nOXSvXIbo= =Mr2I -----END PGP SIGNATURE----- --wg9FEZT+WCTrEXgJ--