in reply to Re: Finding the max()/min()
in thread Finding the max()/min()
Here's another recursive form:
sub max { my( $i, @l ) = @_; my $j = @l ? max( @l ) : $i; return $i > $j ? $i : $j; }
And for that matter, an iterative form:
sub max { $_[ 0 ] < $_[ -1 ] ? shift : pop while @_ > 1; return @_; }
Makeshifts last the longest.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Finding the max()/min()
by elusion (Curate) on Dec 18, 2004 at 17:26 UTC | |
by sleepingsquirrel (Chaplain) on Dec 19, 2004 at 01:40 UTC | |
by elusion (Curate) on Dec 19, 2004 at 02:21 UTC | |
by Aristotle (Chancellor) on Dec 19, 2004 at 05:45 UTC |