"be consistent" 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??

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

Replies are listed 'Best First'.
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";

Create A New User
Domain Nodelet?
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 avoiding work at the Monastery: (5)
As of 2022-01-17 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In 2022, my preferred method to securely store passwords is:

Results (51 votes). Check out past polls.

Notices?