Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Ternary vs. Sort vs. Max

by QM (Parson)
on Aug 10, 2015 at 09:23 UTC ( #1137981=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $n = $x > $y ? $x : $y;
    
  2. or download this
    my $n = (sort {$a <=> $b} $x, $y)[-1];
    
  3. or download this
    use List::Util qw(max);
    my $n = max($x, $y);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1137981]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2021-01-23 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?