Why does this Friday 13th program fail? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Why does this Friday 13th program fail? (/thread-9310.html) |
Why does this Friday 13th program fail? - Joe Horn - 10-16-2017 02:02 PM Perusing old postings I ran across several "Friday The 13th" programs, and whipped up this obvious-ware for the HP Prime. Looks to me like it should work. But it doesn't. Code: EXPORT FRI13(Y) An input of 2017 should return {2017.0113, 2017.1013}, but it only returns {2017.0113}. An input of 2026 should return a list containing 3 dates, but only an empty list is returned. What am I doing wrong? RE: Why does this Friday 13th program fail? - Joe Horn - 10-16-2017 02:04 PM SORRY... please ignore previous posting. My ENDs were in the wrong place. This works: Code: EXPORT FRI13(Y) RE: Why does this Friday 13th program fail? - jebem - 10-16-2017 03:05 PM Thank you for sharing this neat program, Joe. I quit programming long time ago (because I don't need it for my work anymore), so when I looked to the first program listing I couldn't immediately see anything wrong, but the two consecutive END statements following a RETURN did call my attention to check the begin-end code blocks in more detail. I didn't try the program myself, but my understanding is that the Prime interpreter will not detect any anomalies in the first code listing, meaning that from the point of syntax correctness the Prime will find no errors. It seems that in the first posted algorithm, the FOR loop was interrupted due to an early exit imposed by the RETURN statement, right? RE: Why does this Friday 13th program fail? - ggauny@live.fr - 10-16-2017 06:40 PM Hi, From "One-Minute Marvel", from a program of Joe K Horn and one other, I have ported this for HP Prime : Code:
Have a good night (or day !). RE: Why does this Friday 13th program fail? - toml_12953 - 10-16-2017 08:09 PM (10-16-2017 02:02 PM)Joe Horn Wrote: Perusing old postings I ran across several "Friday The 13th" programs, and whipped up this obvious-ware for the HP Prime. Looks to me like it should work. But it doesn't. You already found the problem so I won't elaborate but I do find it helpful to indent structures like FOR, BEGIN, and IF. This lets me see problems with nesting immediately. RE: Why does this Friday 13th program fail? - Joe Horn - 10-17-2017 04:03 AM (10-16-2017 08:09 PM)toml_12953 Wrote: You already found the problem so I won't elaborate but I do find it helpful to indent structures like FOR, BEGIN, and IF. This lets me see problems with nesting immediately. Good advice! RE: Why does this Friday 13th program fail? - Giancarlo - 10-17-2017 05:09 AM Hello Joe, Any particular reason for preferring CONCAT command instead of a L9(0):=j command? Thanks Giancarlo RE: Why does this Friday 13th program fail? - Joe Horn - 10-17-2017 12:17 PM (10-17-2017 05:09 AM)Giancarlo Wrote: Any particular reason for preferring CONCAT command instead of a L9(0):=j command? Yes: I didn't know about L9(0):=j before. Very cool! Thank you! RE: Why does this Friday 13th program fail? - Didier Lachieze - 10-17-2017 08:42 PM In one line: Code: EXPORT FRI13(Y) RE: Why does this Friday 13th program fail? - DrD - 10-17-2017 09:15 PM Amazing! How about creating a drop-in, full featured, bug free, replacement CAS system in the next day or so? RE: Why does this Friday 13th program fail? - Tyann - 10-18-2017 04:22 AM (10-17-2017 08:42 PM)Didier Lachieze Wrote: In one line: Bonjour Je voulais émettre une critique sur ce code, pensant que vous utilisez une variable globale 'J' Je viens de me rendre compte que la variable utilisée par MAKELIST semble maintenant être une variable locale. Est-ce vrai ? Hello I wanted to comment on this code, thinking that you are using a global variable 'J' I have just realized that the variable used by MAKELIST now seems to be a local variable. Is it true ? RE: Why does this Friday 13th program fail? - DrD - 10-18-2017 10:22 AM You can use any variable, local, global, reserved, etc., within the MAKELIST() command. It you want to save the output of the MAKELIST() command, it would need to be in a variable of a legal type, (no RESERVED variables except L0-L9, or M0-M9. [attachment=5269] [attachment=5270] |