Hi,
below is simple solution for union and intersection for a pair of arrays (@a and @b). How
to modify this example that I can calculate union and intersection for each pair of
"n" arrays.
Thanks in advance for any suggestion, Andrej
######################
use warnings;
@a = (1, 3, 5, 6, 7, 8);
@b = (2, 3, 5, 7, 9);
@union = @intersect= ();
%union = %intersect = ();
%count = ();
foreach $e (@a) { $union{$e} = 1 }
foreach $e (@b) {
if ( $union{$e} ) { $isect{$e} = 1 }
$union{$e} = 1;
}
@union = keys %union;
@isect = keys %isect;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>