CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [dwarnold45] Array logic?: Edit Log



BillKSmith
Veteran

Jul 1, 2011, 2:08 PM


Views: 941
Re: [dwarnold45] Array logic?

use the functions "pairwise" and then "any" in the modulle List::MoreUtils.



Code
use strict; 
use warnings;
use List::MoreUtils qw (any pairwise);
our $a;
our $b;
our $c;
my @a=(3, 0,-5, 6);
my @b=(0,-2, 4, 3);
my @c=(4, 0, 4, 3);

die "pair a,b is not compatible\n" if any {$_} pairwise { !$a and !$b } @a, @b;
print 'pair a,b is compatible', "\n";
die "pair a,c is not compatible\n" if any {$_} pairwise { !$a and !$c } @a, @c;
print 'pair a,c is compatible', "\n";

Good Luck,
Bill

(This post was edited by BillKSmith on Jul 1, 2011, 3:22 PM)


Edit Log:
Post edited by BillKSmith (Veteran) on Jul 1, 2011, 3:22 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives