my @simpsons = ("homer","bart","marge","maggie","lisa"); my @females = ("lisa","marge","maggie","maude"); my %simpsons = map{$_ =>1} @simpsons; my %females = map{$_=>1} @females; # the intersection of @females and @simpsons: my @female_simpsons = grep( $simpsons{$_}, @females );
use Quantum::Superpositions; my @a = (1,2,3,4,5,6,7,8,9,10); # integers my @b = (2,4,6,8,10,12,14,16,18,20); # doubled my @unionAB = sort { $a <=> $b } eigenstates( any(@a, @b) ); my @intersectionAB = sort { $a <=> $b } eigenstates( any(@a) == any(@b+) ); my @differenceAB = sort { $a <=> $b } eigenstates( any(@a) != all(@b+) );