in reply to RE: Re: All array elements the same?
in thread All array elements the same?

I don't think it does count as brute force. davorg may disagree, of course, but here are my two cents.

This is brute force:
(Note: this is deliberately not perl-idiom, just to be obtuse...)

my @Unique; for (my $i = 0; $i != @Arr; $i++){ my $Val = $Arr[$i]; my $Found = 0; for (my $j = 0; $j != @Unique; $j++){ if ($Val == $Unique[$j]){ $Found = 1; last; } } if (not $Found){ push @Unique, $Val; } } print 'Unique values are: ', join ', ', @Unique;
Now, in perl idiom, we do all that in one line using a hash. Of course, the specific problem we are solving here would be much simpler, even in 'C' mentality...

I guess my definition of brute-force is "the opposite of perl idiom."

Russ
Brainbench 'Most Valuable Professional' for Perl