From: Joe Van Dyk Date: 2005-10-17T13:30:38+09:00 Subject: Re: How to get non-unique elements from an array? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 16, 2005, at 7:07 PM, Explosiv0SX wrote: > You could just sort the array, then iterate. If the previous > iteration value is equal to the current, you have a non-unique. > This would work with string or numeric data types. > > Rick > > On Oct 16, 2005, at 9:44 PM, Lyndon Samson wrote: > Or, probably not efficient, but: irb(main):031:0> a => [1, 2, 3, 4, 5, 5, 3] irb(main):032:0> a.find_all { |x| a.find_all { |y| y == x }.size > 1 }.uniq => [3, 5] > >> Funny, doesnt work when an item in the array > 10... >> >> Plus, reading the documentation ( doh! ) I can access a Bignum bit >> with [] >> >> >> On 10/17/05, Lyndon Samson wrote: >> >> >>> >>> Not very elegant, but a different approach... >>> >>> bn = bn2 = 0 >>> a.each {|el|(bn2 |= (1<>> (1<>> 0.upto(a.length) { |bitNdx| puts bitNdx if (bn2 & ( 1<>> = 0 } >>> >>> >>> >>> >>> >> >> >> -- >> Into RFID? www.rfidnewsupdate.com >> Simple, >> fast, news. >> >> > > > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFDUyjpsWh6/7z1gt4RAs02AJ4r8HY5/CgXDjfP50hPBaEzpFY+jQCeI8he tA0HUlGZk4eshlTS+xxGmag= =T67U -----END PGP SIGNATURE-----