Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Finding sum of numbers and storing it an Array

by hippo (Chancellor)
on Sep 21, 2020 at 09:20 UTC ( #11121988=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @nums = (5, 10, 15, 20, 25);
    
  2. or download this
    my $totalSum = 0;
    $totalSum += $_ for @nums;
    
  3. or download this
    use List::Util 'sum';
    my $totalSum = sum @nums;
    
  4. or download this
    my @array = map { $_ / $totalSum } @nums;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-03-04 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (102 votes). Check out past polls.

    Notices?