punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
Yes, it's "Yet Another Array Comparison Question". But for a particular case:
I have arrays of simple integers. All I want to do is test if @array_1 contains exactly the same set of integers as @array_2. Yes, or no.
So I figure I should be able to do:
And if they contain the same set of integers, I now have two identical arrays, even if the sort is ascii-betical instead of true numerical.@array_1 = sort(@array_1); @array_2 = sort(@array_2);
THEN - and here's my question - if I can convert the array into a string with no separators, I've got two strings to compare for equality. BUT - other than something heavy like
is there some other way to make my string?$string = join("", @array_1);
Thanks
P.S. - other brilliant ideas are more than welcome!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Compare two arrays of simple numbers
by throop (Chaplain) on Oct 03, 2007 at 02:58 UTC | |
Re: Compare two arrays of simple numbers
by bruceb3 (Pilgrim) on Oct 03, 2007 at 00:00 UTC | |
by bruceb3 (Pilgrim) on Oct 03, 2007 at 00:02 UTC | |
by punch_card_don (Curate) on Oct 03, 2007 at 00:05 UTC | |
| |
Re: Compare two arrays of simple numbers
by GrandFather (Saint) on Oct 03, 2007 at 00:27 UTC | |
Re: Compare two arrays of simple numbers
by andreas1234567 (Vicar) on Oct 03, 2007 at 06:06 UTC | |
Re: Compare two arrays of simple numbers
by Prof Vince (Friar) on Oct 03, 2007 at 08:24 UTC | |
by erroneousBollock (Curate) on Oct 03, 2007 at 08:27 UTC | |
by Prof Vince (Friar) on Oct 03, 2007 at 08:36 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |