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

Re: How can one find out the pairwise difference and product between elements in a perl array without using a perl module?

by Arunbear (Parson)
on Sep 13, 2013 at 13:26 UTC ( #1053933=note: print w/ replies, xml ) Need Help??


in reply to How can one find out the pairwise difference and product between elements in a perl array without using a perl module?

One way (differences and products are left as an exercise):

% perl -E '@a = 1 .. 4; for my $x (@a) { %set = map { $_ => 1 } @a; de +lete $set{$x}; say "$x, $_" for keys %set; }' 1, 4 1, 3 1, 2 2, 4 2, 1 2, 3 3, 4 3, 1 3, 2 4, 1 4, 3 4, 2 %


Comment on Re: How can one find out the pairwise difference and product between elements in a perl array without using a perl module?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2014-12-25 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls