trowa has asked for the wisdom of the Perl Monks concerning the following question:
@union = @intersection = @difference = (); %count = (); foreach $element (@array1, @array2) { $count{$element}++ } foreach $element (keys %count) { push @union, $element; push @{ $count{$element} > 1 ? \@intersection : \@difference }, $e +lement; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: union, intersection, and difference
by particle (Vicar) on May 02, 2002 at 19:49 UTC | |
|
Re: union, intersection, and difference
by thelenm (Vicar) on May 02, 2002 at 19:51 UTC | |
|
Re: union, intersection, and difference
by lachoy (Parson) on May 02, 2002 at 21:37 UTC | |
by trowa (Acolyte) on May 02, 2002 at 22:20 UTC | |
|
Re: union, intersection, and difference
by Mr. Muskrat (Canon) on May 02, 2002 at 20:11 UTC |