- or download this
use Modern::Perl;
...
my @big = split ':', $_[1];
@small ~~ [ grep $_ ~~ @big, @small ];
}
- or download this
sub isSubset {
my $count = my @small = split ':', $_[0];
...
do { $count-- when @big } for @small;
!$count;
}
- or download this
use Modern::Perl;
use Benchmark qw(cmpthese);
...
isSubsetHash => sub { say isSubsetHash( $b, $a ) },
}
);
- or download this
Rate isSubset isSubsetHash isSubsetSmarter
isSubset 143452/s -- -15% -54%
isSubsetHash 169263/s 18% -- -45%
isSubsetSmarter 309705/s 116% 83% --