On Wed, Jul 22, 2009 at 12:11, Bryan R
Harris wrote:
snip
> If your arrays could be very large, it's a waste of cycles to sort the list
> then throw most of that effort away. You could do:
snip
Due to the fact that sort is written in C, it can be faster to sort
than to loop over the array in Perl
On Wed, Jul 22, 2009 at 03:30, sheela b wrote:
> Hi Jenn,
>
> You can fing max and min value as,
>
> my @ar = (1,2,3,4,58,9,2,1);
> my $max = (sort { $b <=> $a } @ar)[0];
> my $min = (sort { $a <=> $b } @ar)[0];
snip
This is only efficient up to about 250 values in @ar, if @ar is going
to have mor
> You can fing max and min value as,
>
> my @ar = (1,2,3,4,58,9,2,1);
> my $max = (sort { $b <=> $a } @ar)[0];
> my $min = (sort { $a <=> $b } @ar)[0];
If your arrays could be very large, it's a waste of cycles to sort the list
then throw most of that effort away. You could do:
**
thanks all the suggestions.
On Wed, Jul 22, 2009 at 4:32 PM, Shawn H. Corey wrote:
> Jenn G. wrote:
>>
>> Hello,
>>
>> How to lookup the max and min value in an array?
>> Just like SQL's max() and min() functions.
>>
>> Thanks.
>>
>
> use List::Util qw/min max/;
>
> See `perldoc List::Util` for de
Jenn G. wrote:
Hello,
How to lookup the max and min value in an array?
Just like SQL's max() and min() functions.
Thanks.
use List::Util qw/min max/;
See `perldoc List::Util` for details.
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and c
Hi Jenn,
You can fing max and min value as,
my @ar = (1,2,3,4,58,9,2,1);
my $max = (sort { $b <=> $a } @ar)[0];
my $min = (sort { $a <=> $b } @ar)[0];
Regards
Sheela
On Wed, Jul 22, 2009 at 12:48 PM, Jenn G. wrote:
> Hello,
>
> How to lookup the max and min value in an array?
> Just like SQL's
Hello,
How to lookup the max and min value in an array?
Just like SQL's max() and min() functions.
Thanks.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/