for (2) I presume you just compare the number of elements in @union and in @isec?use strict; use warnings; my @x = (-60..-45); my @y = (-57..-49); my %union; my %isect; foreach my $e (@x, @y) { $union{$e}++ && $isect{$e}++ } my @union = sort { $a <=> $b} keys %union; my @isect = sort { $a <=> $b} keys %isect; print "union: @union\n"; print "intersection: @isect\n"; __END__ union: -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 intersection: -57 -56 -55 -54 -53 -52 -51 -50 -49
In reply to Re: union and intersection of ranges
by Marshall
in thread union and intersection of ranges
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |