Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Sum group of numbers and display each number is on its own line

by toolic (Bishop)
on Nov 11, 2017 at 19:25 UTC ( #1203192=note: print w/replies, xml ) Need Help??


in reply to Dice roll chances

One way is to use "sum" from List::Util:
use strict; use warnings; use List::Util qw(sum shuffle); use List::MoreUtils qw(natatime); use feature qw(say); my $iterator = natatime 5, shuffle( 1 .. 50 ); my $count = 1; while ( my @five = $iterator->() ) { say sum(@five); $count++; last if $count > 5; }

See also:

  • Comment on Re: Sum group of numbers and display each number is on its own line
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2020-10-24 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?