Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Comparing two arrays

by AnomalousMonk (Archbishop)
on Feb 21, 2015 at 06:31 UTC ( [id://1117404]=note: print w/replies, xml ) Need Help??


in reply to Comparing two arrays

This is probably not appropriate code for a novice and may, in addition, be problematic because it is not the most maintainable, but...

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "use List::MoreUtils qw(all); ;; my @ra_1 = (13, 29, 545); my @ra_2 = (5, 7, 9); ;; my @ra_3 = grep { my $e_1 = $_; all { $e_1 % $_ } @ra_2 } @ra_1; dd \@ra_3; " [13, 29]
See grep, List::MoreUtils::all and Data::Dump::dd.

Update: Changed List::MoreUtils::any to List::MoreUtils::all, Data::Dump to Data::Dump::dd in reference links.


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

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

    No recent polls found