On Thursday, April 11, 2002, at 01:42  PM, Jeff 'japhy' Pinyan wrote:

> On Apr 11, Bryan R Harris said:
>
>> $someVar = max(@listofvalues);
>>
>> Is there a function in perl like this?
>
> You could use the List::Util module (from CPAN).  Or, you could write your
> own:
>
>   sub max {
>     my $max = shift;
>     for (@_) { $max = $_ if $_ > $max }
>     return $max;
>   }
>

i like:
$max=0;
map {$max=$_ if($_>$max)} @listofvalues;

> --
> Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
> ** Look for "Regular Expressions in Perl" published by Manning, in 2002 *
> *
> <stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
> [  I'm looking for programming work.  If you like my work, let me know.  
> ]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to