Andy Cooper
1/13/2009 10:31:00 PM
> Andy Cooper wrote:
> >=20
> > Without really looking into it a quick and dirty way would=20
> be to just
> > subtract the results of .uniq from the initial array.
> >=20
> > Andy Cooper.
>=20
> Thanks for the quick reply! However, after trying it, I found that=20
> subtracting an array from an array will delete each instance of an=20
> element, leaving me with a blank array, IE:
>=20
> [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=3D> [ 3, 3, 5 ]
>=20
> Any other ideas?
>=20
> Thanks again,
> - Jeff Miller
> --=20
Yeah, I am winning the typing contest today.
> def dups(ary=3D[])
> uniq=3Dary.uniq
> ary.reject{|z| if(uniq.include?(z));q-=3D[z];true;end}
> end
Should actually be
def dups(ary=3D[])
uniq=3Dary.uniq
ary.reject{|z| if(uniq.include?(z));uniq-=3D[z];true;end}
end
Made a mistake when I made q make more sense aparently.
Andy Cooper