Post Reply 
Why does this Friday 13th program fail?
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.

Code:
EXPORT FRI13(Y)
BEGIN
   LOCAL j;
   L9:={};
   FOR j FROM Y+.0113 TO Y+.1213 STEP .01 DO
      IF DAYOFWEEK(j)==5 THEN L9:=CONCAT(L9,j);
   END;
   RETURN L9;
   END;  // What does this close?
END;

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?

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?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Why does this Friday 13th program fail? - toml_12953 - 10-16-2017 08:09 PM



User(s) browsing this thread: 2 Guest(s)