The 1st pass through map allows "user" and "smtp". ("fetch" would be skipped.)
The 2nd pass through map allows "user" and "smtp". ("forward" would be skipped.)
The 3rd pass through map allows "smtp". ("user" is skipped.)
The 4th pass through map allows "user". ("smtp" is skipped.)
One solution (Set arithmetic using a hash):
sub create_list { my %dbs = map { $_ => 1 } qw/fetch forward user smtp/; delete @dbs{@_}; return keys %dbs; }
Another solution (Set arithmetic using a superposition):
use Quantum::Superpositions; sub create_list { my $dbs = any qw/fetch forward user smtp/; my $skip = all @_; return eigenstates( $dbs ne $skip ); }
Another solution (Set arithmetic using sets [seemed appropriate at the time]):
use Set::Scalar qw( ); sub create_list { my $dbs = Set::Scalar->new( qw/fetch forward user smtp/ ); my $skip = Set::Scalar->new( @_ ); return ($dbs - $skip)->members(); }
Update: Added second and third snippet.
In reply to Re: Difference Quantity of two Arrays
by ikegami
in thread Difference Quantity of two Arrays
by ocs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |