Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: minimum, maximum and average of a list of numbers at the same time

by LucaPette (Friar)
on Nov 10, 2005 at 12:20 UTC ( #507350=note: print w/ replies, xml ) Need Help??


in reply to Re: minimum, maximum and average of a list of numbers at the same time
in thread minimum, maximum and average of a list of numbers at the same time

I'm not a perl expert... infact i'm not able to really understand the code of List::Util maybe you can clarify to me about this question: Do your code process three times the input list?


Comment on Re^2: minimum, maximum and average of a list of numbers at the same time
Re^3: minimum, maximum and average of a list of numbers at the same time
by broquaint (Abbot) on Nov 10, 2005 at 12:41 UTC
    Do your code process three times the input list?
    Indeed it does and as davorg and demerphq have pointed out in their replies it isn't terribly efficient, but that's a "perlish" solution for you.
    HTH

    _________
    broquaint

Re^3: minimum, maximum and average of a list of numbers at the same time
by blazar (Canon) on Nov 10, 2005 at 14:36 UTC

    But you're not required to understand it. But then of course without even having seen it I'm sure it does process it three times. If that is really relevant, then indeed you may want or have to process it once yourself. And if it is very relevant, perhaps you may want to do it as a binary extension.

    Well, the author may consider a adding to List::Util a function to calculate more than one relevant quantity at a time, e.g.

    my ($min, $max, $sum) = calculate [qw/min max sum/], @list;

    or perhaps with an OO interface:

    my $stats=List::Util->calculate([qw/min max sum/])->of(@list); print $stats->min, "\n";

    possibly even with a mixed interface:

    calculate [qw/min max sum/], @list; print List::Util::lastrun->max, "\n";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-09-22 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (205 votes), past polls