Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Ternary vs. Sort vs. Max

by QM (Parson)
on Aug 10, 2015 at 09:23 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found