On Monday, April 22, 2002, at 11:53 , Nikola Janceski wrote:
>
> Gosh.. what ever happened to good ol' grep
>
> my %seen;
> @uniq = grep !$seen{$_}++, @array;
http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/
will show you that this works just slightly slower than just
the has
On Monday, April 22, 2002, at 03:43 , Alfred Vahau wrote:
> Assuming that the array has been converted to a scalar, then the
> following "Lookaround Assertion" works:
>
> #!/usr/bin/perl
>
> $_ = 'a a a b b c c';
>
> 1 while s/\b(\w+) \s (?= \1\b ) //gxi;
> print $_, "\n";
Survey Says:
Benchma
Assuming that the array has been converted to a scalar, then the
following "Lookaround Assertion" works:
#!/usr/bin/perl
$_ = 'a a a b b c c';
1 while s/\b(\w+) \s (?= \1\b ) //gxi;
print $_, "\n";
The scalar can be reconverted to an array.
Not sure if this is any faster.
Alfred,
Project Bree
Ok, thanks !
I read it and every thing becomes clear to me :-)
José.
Jenda Krynicky <[EMAIL PROTECTED]> a écrit : From: José Nyimi
> this slice thing is really very nice.
>
> @hash{@array1}=@array2;
>
> I saw it many times used in constructor of "Object Oriented" Perl's
> code.
>
> Could you
From: José Nyimi <[EMAIL PROTECTED]>
> this slice thing is really very nice.
>
> @hash{@array1}=@array2;
>
> I saw it many times used in constructor of "Object Oriented" Perl's
> code.
>
> Could you explain sequencely the syntax please ?
Well I don't think I can make up a better explanation than
Gosh.. what ever happened to good ol' grep
my %seen;
@uniq = grep !$seen{$_}++, @array;
> -Original Message-
> From: Jon Howe [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 22, 2002 12:30 PM
> To: [EMAIL PROTECTED]
> Subject: remove duplicate values from array
>
Hé ! Jenda
this slice thing is really very nice.
@hash{@array1}=@array2;
I saw it many times used in constructor of "Object Oriented" Perl's code.
Could you explain sequencely the syntax please ?
José.
-
Yahoo! Mail -- Une adresse @yahoo.fr gratuite et en f
From: drieux <[EMAIL PROTECTED]>
> On Monday, April 22, 2002, at 09:29 , David Gray wrote:
>
> >> Can anyone tell me the best method for removing duplicate
> >> array values.
> >>
> >> eg:
> >>
> >> @array = qw( a a a b b b c);
> >>
> >> becomes after some operation I cant seem to figure:
> >>
>
On Monday, April 22, 2002, at 09:29 , David Gray wrote:
>> Can anyone tell me the best method for removing duplicate
>> array values.
>>
>> eg:
>>
>> @array = qw( a a a b b b c);
>>
>> becomes after some operation I cant seem to figure:
>>
>> @new_array_or_same = (a b c);
>
> In this situation,
i`m not quite shure because i`m a newbie to, but
try using some RegExp like tr///
and dont forget that tr// and s// have many more functions ex. using the
(?). The book that i find most explainable about RegExp is Beginning Perl
from Wrox Publishing.
-
Cheers,
Miroslav Nikol
> Can anyone tell me the best method for removing duplicate
> array values.
>
> eg:
>
> @array = qw( a a a b b b c);
>
> becomes after some operation I cant seem to figure:
>
> @new_array_or_same = (a b c);
In this situation, I usually use a hash instead of an array so I can
create highly
On Apr 22, Jon Howe said:
>Can anyone tell me the best method for removing duplicate array values.
I think the FAQ answers this best.
perldoc -q uniq
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://
Can anyone tell me the best method for removing duplicate array values.
eg:
@array = qw( a a a b b b c);
becomes after some operation I cant seem to figure:
@new_array_or_same = (a b c);
13 matches
Mail list logo