Day of the week: Difference between revisions

m
(→‎{{header|Commodore BASIC}}: Add implementation.)
Line 587:
This takes advantage of the dynamic scope of arguments to DEF FN functions to nest definitions and ultimately turn the question "Does Christmas fall on a Sunday in year Y?" into a single Boolean function of the year number. It's easy to run afoul of stack limitations in Microsoft BASICs doing this, especially on older versions that just use the processor's 256-byte stack instead of giving BASIC its own, but this program runs fine even on an unexpanded VIC-20.
 
<lang basic>100 REM FIND OUT WHAT YEARS HAVE CHRSITMASCHRISTMAS ON A SUNDAY
110 REM MODULO FUNCTION (USES CALLER'S Y AS DIVIDEND)
120 DEF FNYM(D) = Y - D * INT(Y/D)
1,480

edits