Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^8: How to write testable command line script? (updated)

by thechartist (Monk)
on Nov 26, 2018 at 17:47 UTC ( [id://1226374]=note: print w/replies, xml ) Need Help??


in reply to Re^7: How to write testable command line script? (updated)
in thread How to write testable command line script?

I agree that this alternate method is correct; my question now is if my transliteration of his base 60 algorithm has flaws that I did not initially see. I want to make an argument that these are 2 separate ways of describing the same point, but I do not have a proof yet.

  • Comment on Re^8: How to write testable command line script? (updated)

Replies are listed 'Best First'.
Re^9: How to write testable command line script? (updated)
by AnomalousMonk (Archbishop) on Nov 26, 2018 at 21:19 UTC
    ... these are 2 separate ways of describing the same [angle] ...

    There are an infinite number of ways to describe any angle. I see nothing inherently wrong with representing -0° 1' 0" (or 0°, -1', 0" in a different notation) as  (-1, 59, 0) internally as long as this tuple (and all such "weird" tuples; there are many in the test sets) correctly reduce to whatever you define as a "standard" representation (and the aforementioned tuple does reduce to  (0, -1, 0) as shown below). In the end, it's all a matter of the constraints you choose to impose on, e.g., notation and internal representation, user input, user output, etc., etc. These are all programmer choices.

    c:\@Work\Perl\monks\thechartist>perl -wMstrict -le "use TrigCalc qw(reduce); ;; my @dms = reduce(-1, 59, 0); print qq{(@dms)}; " (0 -1 0)
    That said, simplest is usually best, so my choice for the internal representation of this angle would be -60 arc-seconds (or maybe decimal degrees, or radians, or whatever).


    Give a man a fish:  <%-{-{-{-<

      Thanks for coming back to this. I was about to go into detail showing how my representation, at least for the purposes of addition and subtraction, was equivalent, but you had already done that for me.

      After starting this script, I later realized that my initial algorithm did not handle division correctly. I believe you method of converting everything to seconds is the most general and will likely be what I implement when I revise this.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (None)
    As of 2024-04-25 00:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found