Anonymous user
Last Friday of each month: Difference between revisions
Minor change in the program to print each date on a separate line
(The K language code given for printing dates of last Fridays of all months a given year.) |
(Minor change in the program to print each date on a separate line) |
||
Line 1,748:
init: {:[isleap x;dom[1]::29;dom[1]::28]}
wdme: {[m;y]; init y; dt:(10000*y)+(100*m)+dom[m-1];jd::(_jd dt);mewd::(wd dt)}
lfd: {[m;y]; wdme[m;y];:[mewd>3;jd::jd+(4-mewd);jd::jd-(3+mewd)];dt:_dj(jd);yy:$(yr:dt%10000);dd:$(d:dt!100);mm:$(mo:((dt-yr*10000)%100));arr::arr,
lfd1: {[y];arr::(); m:1; do[12;lfd[m;y];m+:1]}
main: {[y]; lfd1[y];`0: ,"Dates of last Fridays of ",($y);12 10#arr}
</lang>
The output of a session is given below:
Line 1,759 ⟶ 1,760:
\l lastfridt
main 2012
Dates of last Fridays of 2012
("2012- 1-27"
"2012- 2-24"
"2012- 3-30"
"2012- 4-27"
"2012- 5-25"
"2012- 6-29"
"2012- 7-27"
"2012- 8-31"
"2012- 9-28"
"2012-10-26"
"2012-11-30"
"2012-12-28")
</pre>
|