Why does this Friday 13th program fail?
|
10-16-2017, 02:02 PM
(This post was last modified: 10-16-2017 02:02 PM by Joe Horn.)
Post: #1
|
|||
|
|||
Why does this Friday 13th program fail?
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? <0|ɸ|0> -Joe- |
|||
10-16-2017, 02:04 PM
Post: #2
|
|||
|
|||
RE: Why does this Friday 13th program fail?
SORRY... please ignore previous posting. My ENDs were in the wrong place. This works:
Code: EXPORT FRI13(Y) <0|ɸ|0> -Joe- |
|||
10-16-2017, 03:05 PM
Post: #3
|
|||
|
|||
RE: Why does this Friday 13th program fail?
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? Jose Mesquita RadioMuseum.org member |
|||
10-16-2017, 06:40 PM
(This post was last modified: 10-16-2017 07:09 PM by ggauny@live.fr.)
Post: #4
|
|||
|
|||
RE: Why does this Friday 13th program fail?
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 !). Gérard. |
|||
10-16-2017, 08:09 PM
(This post was last modified: 10-16-2017 08:11 PM by toml_12953.)
Post: #5
|
|||
|
|||
RE: Why does this Friday 13th program fail?
(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. Tom L Cui bono? |
|||
10-17-2017, 04:03 AM
Post: #6
|
|||
|
|||
RE: Why does this Friday 13th program fail?
(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! <0|ɸ|0> -Joe- |
|||
10-17-2017, 05:09 AM
Post: #7
|
|||
|
|||
RE: Why does this Friday 13th program fail?
Hello Joe,
Any particular reason for preferring CONCAT command instead of a L9(0):=j command? Thanks Giancarlo |
|||
10-17-2017, 12:17 PM
Post: #8
|
|||
|
|||
RE: Why does this Friday 13th program fail?
(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! <0|ɸ|0> -Joe- |
|||
10-17-2017, 08:42 PM
Post: #9
|
|||
|
|||
RE: Why does this Friday 13th program fail?
In one line:
Code: EXPORT FRI13(Y) |
|||
10-17-2017, 09:15 PM
(This post was last modified: 10-17-2017 09:19 PM by DrD.)
Post: #10
|
|||
|
|||
RE: Why does this Friday 13th program fail?
Amazing!
How about creating a drop-in, full featured, bug free, replacement CAS system in the next day or so? |
|||
10-18-2017, 04:22 AM
(This post was last modified: 10-18-2017 04:23 AM by Tyann.)
Post: #11
|
|||
|
|||
RE: Why does this Friday 13th program fail?
(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 ? Sorry for my english |
|||
10-18-2017, 10:22 AM
(This post was last modified: 10-18-2017 10:33 AM by DrD.)
Post: #12
|
|||
|
|||
RE: Why does this Friday 13th program fail?
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] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)