Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Summing the elements of multiple arrays into a new array

by Aighearach (Initiate)
on Nov 01, 2001 at 01:12 UTC ( [id://122433]=note: print w/replies, xml ) Need Help??


in reply to Summing the elements of multiple arrays into a new array

without measuring lengths or worring about that...
(use a #12 hook for the void map...)
map { $sum += $_ } @foo, @bar;
or if you're not fi^H^Hgolfing:
use strict; my $sum = 0; my @foo = ( 2,4,6,8 ); my @bar = ( 200,400,600,800 ); foreach (@foo,@bar) { $sum += $_; }

--
Snazzy tagline here

Log In?
Username:
Password:

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

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

    No recent polls found