Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I get an array which is the logical AND of the elements of two other arrays?

by GrandFather (Saint)
on Feb 25, 2006 at 22:58 UTC ( [id://532815]=note: print w/replies, xml ) Need Help??


in reply to How do I get an array which is the logical AND of the elements of two other arrays?

List::Compare may well be what you are looking for - reinventing wheels and all that.

use warnings; use strict; use Data::Dump::Streamer; use List::Compare; my @A = ('1', '2', '4', '8'); my @B = ('1', '3', '6', '8'); my $lc = List::Compare->new (\@A, \@B); my @intersect = $lc->get_intersection; my @AOnly = $lc->get_Lonly; my @BOnly = $lc->get_Ronly; print "Intersection: @intersect\n"; print "A only: @AOnly\n"; print "B only: @BOnly\n";

Prints:

Intersection: 1 8 A only: 2 4 B only: 3 6

DWIM is Perl's answer to Gödel
  • Comment on Re: How do I get an array which is the logical AND of the elements of two other arrays?
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://532815]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-16 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found