- or download this
use strict;
use warnings;
...
my $diff = relative_complement( list_2_hashref( @A ),
list_2_hashref( @B ) );
- or download this
sub intersection {
my %tally;
$tally{ $_ }++ for map keys %$_, @_;
return list_2_hashref( grep $tally{ $_ } == @_, keys %tally );
}
- or download this
sub sym_diff {
my %tally;
$tally{ $_ }++ for map keys %$_, @_[0, 1];
return list_2_hashref( grep $tally{ $_ } == 1, keys %tally );
}
- or download this
my $A = list_2_hashref( qw( a b c ) );
my $B = list_2_hashref( qw( b c d ) );
...
symmetric difference A, B:
'a' => 1
'd' => 1
- or download this
use strict;
use warnings;
...
relative complement A, B: (a)
intersection A, B, C: (c)
symmetric difference A, B: (a d)