Top three calculators ?
|
08-18-2018, 04:41 PM
Post: #83
|
|||
|
|||
RE: Top three calculators ?
(04-05-2018 10:16 AM)Pekis Wrote: But I think no one can deny that the mind can't figure instantly what all these stack operations are doing in RPL (and RPN), and you'll end up documenting with pseudo-code tasting like ... BASIC: This formula is from Zeller's congruence: \(h=\left(q+\left\lfloor {\frac {13(m+1)}{5}}\right\rfloor +K+\left\lfloor {\frac {K}{4}}\right\rfloor +\left\lfloor {\frac {J}{4}}\right\rfloor -2J\right){\bmod {7}}\) where
NOTE: In this algorithm January and February are counted as months 13 and 14 of the previous year. Here's a possible implementation for the HP-48G: ( mm dd yyyy -- dow ) Code: « ROT Using local variables helps to avoid stack acrobatics. It makes code maintainable without the need of pseudo-code in comments. My rule of thumb is not juggling with more than three objects on the stack. Valentin is able to write BASIC-code for the HP-71B that I often don't understand at a first glimpse. But that's okay when he's playing code golf. Thus it's not so much about the language but about your attitude when writing code. I agree with you though in terms of RPN due to its lack of local variables and means to structure code and data. There it helps to have a mapping of variable names to registers, stack-diagrams or the implementation of the algorithm in a language like Python. Kind regards Thomas I had a hard time understanding your code but that was more related to the question of why you used a different formula for handling m? Just so you can start the list of weekdays with "Sunday" instead of "Saturday"? Or is it based on a different source for the algorithm? Or then why don't you reuse c in the calculation of d? Code: c = int(yr/100) BTW: There's a typo in your RPL code: "Thrusday" → "Thursday" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)