Perlist at blogspot
2012/07/23
Unique values (Perl)
use List::MoreUtils qw( uniq );
@arr = qw( 4 4 2 2 );
@arr = uniq @arr;
print "@arr\n";
# =====
my @uniq = unique( @in );
sub unique
{
my %seen;
return grep {!$seen{$_}++} @_;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment