Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If “that’s the whole point of it,” as you say, then I can’t speak to that.   (And, mind you, I do not intend in any way to judge that.)   All that I can say is that I believe one should always look for the simplest, the most obvious, and of course the reasonably least-expensive way to do something.   “If what you are doing should require no thought, pretty-please don’t make me think about it.”

For instance, if you want to find the largest value in a list ... say, the largest card in your poker hand ... then you do not need to sort the list to find that out.   Your eyes can make a single furtive glance over your hand, and now you know.   Therefore, I would not ask the computer to perform any extra work for me, if it would not pay off otherwise.

As for the other two, ternary operators work really well in the place where (I think) they were intended:   when you want to make a simple, either/or choice in an arithmetic expression.   But, I always want to see my “glance rule” clearly upheld.   I want to always see, “at a glance,” exactly what I expect to see.

I like things like max() simply because they are nice and expressive.   They clearly say what is “the designer’s intent.”   In most languages they will do just the right thing, efficiently.

As an aside, I encountered one programming language ... HP/2000 Access BASIC ... which had a MAX/MIN operator.   It was so very expressive ... such a nice feature.


In reply to Re: Ternary vs. Sort vs. Max by sundialsvc4
in thread Ternary vs. Sort vs. Max by QM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (4)
    As of 2019-05-23 06:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Do you enjoy 3D movies?



      Results (142 votes). Check out past polls.

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