Doomsday rule: Difference between revisions

Content added Content deleted
(added Perl programming solution)
m (→‎{{header|REXX}}: simplified some code.)
Line 895: Line 895:
y.1= 4 1 7 4 2 6 4 1 5 3 7 5 /* " " " leapyear " */
y.1= 4 1 7 4 2 6 4 1 5 3 7 5 /* " " " leapyear " */


do j=1 for words($) /*process each of the dates. */
do j=1 for words($); datum= word($, j) /*process each of the dates. */
parse value word($, j) with mm '/' dd "/" yy /*parse the date ──► mm dd yy */
parse var datum mm '/' dd "/" yy /*parse the date ──► mm dd yy */
ly= leapyear(yy) /*get indication of a leapyear.*/
ly= leapyear(yy) /*get indication of a leapyear. */
wd= (doomsday(yy)+dd-word(y.ly, mm) + 7) // 7 + 1 /*obtain code for the weekday. */
wd= (doomsday(yy)+dd-word(y.ly, mm) + 7) // 7 + 1 /*obtain a code for the weekday.*/
say mm'/'dd"/"yy ' falls on ' word(d, wd)"day" /*display day-of-week for date.*/
say datum ' falls on ' word(d, wd)"day" /*display day-of-week for date. */
end /*j*/
end /*j*/
exit 0 /*stick a fork in it, we're all done. */
exit 0 /*stick a fork in it, we're all done. */