Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: simultaneously adding and multiplying numbers in a hash/ array

by ikegami (Patriarch)
on Aug 09, 2010 at 21:44 UTC ( [id://853923]=note: print w/replies, xml ) Need Help??


in reply to simultaneously adding and multiplying numbers in a hash/ array

The hash is neither required nor helpful.
my @change = (1.15, -0.1, 5.4, 1.03, -0.241); my @numberofshares = (100, 400, 200, 300, 240); my $product = 0; for (0..$#change) { $product += $change[$_] * $numberofshares[$_]; }
  • Comment on Re: simultaneously adding and multiplying numbers in a hash/ array
  • Download Code

Log In?
Username:
Password:

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

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

    No recent polls found