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

Re^3: Ternary vs. Sort vs. Max

by sundialsvc4 (Abbot)
on Aug 11, 2015 at 03:35 UTC ( #1138103=note: print w/replies, xml ) Need Help??


in reply to Re^2: Ternary vs. Sort vs. Max
in thread Ternary vs. Sort vs. Max

Are you really serious, “Mom?”

Pardon me, ladies and gentlemen, while I “ROTFMAO™” ... and conclude, most graciously, that seriousness in this matter simply cannot be possible.

O-p-e-r-a-t-o-r-:   a unary or binary element within an arithmetic expression, viz:

445 IF (A MAX B) > 5 THEN 550

It very elegantly captures the most-common use case for a ternary operator, without requiring a function-call having two or more arguments (which that language did not support).

Replies are listed 'Best First'.
Re^4: Ternary vs. Sort vs. Max
by Laurent_R (Canon) on Aug 12, 2015 at 21:31 UTC
    You should really take a look at Perl 6: it enables you to build your own infix max operator in just a couple of code lines (see for example Moritz's tutorial on the subject: http://perlgeek.de/en/article/5-to-6#post_13). So that you could have something like:
    if ($c max $d > 5) { # ... }
    Oh, but I forgot, you absolutely (and unreasonably IMHO) hate Perl 6, too bad for you, or maybe you should reconsider your opinion on the subject.

    And, BTW, NO, I did not downvote your post. If anyone did, it's not me.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2019-04-21 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (110 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!