Re: efficient max() function from sort
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Wed, 28 May 2008 19:37:15 -0700
Chas. Owens wrote:
On Wed, May 28, 2008 at 5:07 PM, Rob Dixon <rob.dixon@xxxxxxx> wrote:
snip
$max = (sort {$a <=> $b} @z)[-1];snip
my $max = (sort { $b <=> $a } @z)[0];
is slightly faster than using [-1].
Or:
my ( $max ) = sort { $b <=> $a } @z;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- References:
- efficient max() function from sort
- From: Ramprasad A Padmanabhan
- Re: efficient max() function from sort
- From: Rob Dixon
- Re: efficient max() function from sort
- From: Chas. Owens
- efficient max() function from sort
- Prev by Date: Re: assign default value to variables I assign from split
- Next by Date: Re: assign default value to variables I assign from split
- Previous by thread: Re: efficient max() function from sort
- Next by thread: Curses - chgat
- Index(es):
Relevant Pages
|
|