in reply to What I Most Recently Learned in Perl, But Should Have Already Known
Map and grep.
Especially for set functions, e.g. (untested code, but that should give the idea)
my @a=(1,2,3,4,5); my @b=(4,5,6,7,8); my %a = map { $_ => 1 } @a; my %b = map { $_ => 1 } @b; my @intersection = grep { exists $a{$_} } @b; my @intersection_complement = grep { !exists $a{$_} } @b;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: What I Most Recently Learned in Perl, But Should Have Already Known
by pKai (Priest) on Aug 23, 2006 at 08:49 UTC |
In Section
Meditations