Day of the week: Difference between revisions
Content added Content deleted
m (→{{header|GAP}}: xmas function is better replaced with "Filtered" + WeekDay implementation) |
|||
Line 727: | Line 727: | ||
=={{header|GAP}}== |
=={{header|GAP}}== |
||
<lang gap> |
<lang gap>Filtered([2008 .. 2121], y -> WeekDay([25, 12, y]) = "Sun"); |
||
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ] |
|||
local y, v; |
|||
⚫ | |||
# A possible implementation of WeekDayAlt |
|||
for y in [a .. b] do |
|||
if WeekDay([25, 12, y]) = "Sun" then |
|||
WeekDayAlt := function(args) |
|||
⚫ | |||
local d, m, y, k; |
|||
⚫ | |||
⚫ | |||
m := args[2]; |
|||
⚫ | |||
y := args[3]; |
|||
if m < 3 then |
|||
m := m + 12; |
|||
⚫ | |||
⚫ | |||
k := 1 + RemInt(d + QuoInt((m + 1)*26, 10) + y + QuoInt(y, 4) |
|||
+ 6*QuoInt(y, 100) + QuoInt(y, 400) + 5, 7); |
|||
⚫ | |||
end; |
end; |
||
Filtered([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> |
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]</lang> |
||