develooper Front page | perl.beginners | Postings from February 2002

Re: finding max value

Thread Previous | Thread Next
February 13, 2002 04:59
Re: finding max value
Message ID:
On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote:
> In article <> wrote "Jeff 'Japhy' Pinyan"
> <>:
> >>I have a set of functions that give numeric results, and I need to compare  them and choose the
> >>maximal value. Is there any simple way of finding max?
> Don't think about it,
> just use the CPAN module List::Util.
> Then you only have to write 
> my $max = max @values;
---end quoted text---

$max= (sort @values)[-1];

Personally, I'd prefer Japhy's method for efficiency.

 Frank Booth - Consultant
Parasol Solutions Limited.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About