Jump to content

Day of the week: Difference between revisions

m
→‎{{header|GAP}}: xmas function is better replaced with "Filtered" + WeekDay implementation
m (→‎{{header|GAP}}: xmas function is better replaced with "Filtered" + WeekDay implementation)
Line 727:
 
=={{header|GAP}}==
<lang gap>xmasFiltered([2008 :=.. function2121], y -> WeekDay(a[25, b12, y]) = "Sun");
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]
local y, v;
 
v := [ ];
# A possible implementation of WeekDayAlt
for y in [a .. b] do
 
if WeekDay([25, 12, y]) = "Sun" then
WeekDayAlt := function(args)
Add(v, y);
local fid, m, y, k;
v d := args[ 1];
od;
m := args[2];
return v;
y := args[3];
if m < 3 then
m := m + 12;
Add(v,y := y) - 1;
od fi;
k := 1 + RemInt(d + QuoInt((m + 1)*26, 10) + y + QuoInt(y, 4)
+ 6*QuoInt(y, 100) + QuoInt(y, 400) + 5, 7);
return vdays[k];
end;
 
xmasFiltered([2008, .. 2121);], y -> WeekDayAlt([25, 12, y]) = "Sun");
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.