Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How do I multiply the corresponding elements in two arrays together?

by Russ (Deacon)
on Nov 30, 2000 at 00:28 UTC ( [id://44001]=note: print w/replies, xml ) Need Help??


in reply to How do I multiply the corresponding elements in two arrays together?

I hate to use array indices, but here's one way:
my @Products = map {$Arr1[$_] * $Arr2[$_]} 0..$#Arr1;
This assumes that the arrays @Arr1 and @Arr2 exist and are the same length.
  • Comment on Re: How do I multiply the corresponding elements in two arrays together?
  • Download Code

Log In?
Username:
Password:

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

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

    No recent polls found