Day of the week: Difference between revisions

Added MiniScript
(Added PL/M)
(Added MiniScript)
 
(5 intermediate revisions by 5 users not shown)
Line 2,125:
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
procfunc dayOfTheWeek year month day . result .
# Based on Conway's doomsday algorithm
# 1. Calculate the doomsday for the century
Line 2,189:
NthDay += day
# 6. Finally, calculate the day of the week
result =return (januaryOne + NthDay - 1) mod 7
.
for i = 2008 to 2121
callif dayOfTheWeek i 12 25 result= 0
if result = 0
print "Christmas in " & i & " is on Sunday"
.
Line 2,681 ⟶ 2,680:
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Day_of_the_week}}
 
'''Solution'''
 
[[File:Fōrmulæ - Day of the week 01.png]]
 
[[File:Fōrmulæ - Day of the week 02.png]]
 
=={{header|Frink}}==
Line 3,176 ⟶ 3,181:
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</syntaxhighlight>
 
=={{header|Koka}}==
<syntaxhighlight lang="koka">
import std/time/date
import std/time/calendar
import std/time/instant
import std/time/utc
 
fun main()
for(2008, 2121) fn(year)
val i = instant(year, 12, 25, cal=cal-gregorian)
val dow = (i.days+6)%7 // plus 6 since 2000-01-01 epoch was a Saturday
match dow.weekday
Sun -> println(year.show)
_ -> ()
</syntaxhighlight>
 
{{out}}
<pre>
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</pre>
 
=={{header|Kotlin}}==
Line 3,560 ⟶ 3,602:
lambda([y], weekday(y, 12, 25) = 'sunday));
/* [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118] */</syntaxhighlight>
 
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">import "dateTime"
 
print "Years between 2008 and 2121 when 25th December falls on Sunday:"
years = []
for year in range(2008, 2121)
date = year + "-12-25"
if dateTime.weekday(date) == 0 then years.push year
end for
print years.join(", ")</syntaxhighlight>
 
{{out}}
<pre>Years between 2008 and 2121 when 25th December falls on Sunday:
2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118
</pre>
 
=={{header|МК-61/52}}==
Line 5,105 ⟶ 5,163:
=={{header|RPL}}==
Early RPL versions do not have any date library, so a specific instruction implement Zeller's congruence with a stack-oriented algorithm.
{{works with|Halcyon CalcHP|4.2.728}}
≪ '''IF''' OVER 2 ≤ '''THEN''' 1 - SWAP 12 + SWAP '''END'''
100 MOD LAST / FLOOR
Line 5,111 ⟶ 5,169:
SWAP 1 + 13 * 5 / FLOOR + +
7 MOD 5 + 7 MOD 1 +
≫ ''''<span style="color:blue">WKDAY'''</span>' STO
In 1990, RPL gained some basic functions for calculating the date, but nothing for directly obtaining the day of the week.
{{works with|HP|48}}
≪ { "MON" TUE" "WED" "THU" "FRI" "SAT" "SUN" }
SWAP 0 TSTR 1 3 SUB POS
≫ '<span style="color:blue">WKDAY</span>' STO <span style="color:grey">@ ( dd.mmyyyy → 1..7 )</span>
 
≪ { } 2008 2121 '''FOR''' year
'''IF''' 25 12 year '''<span style="color:blue">WKDAY'''</span> 7 == '''THEN''' year + '''END NEXT'''
≫ EVAL
{{out}}
Line 6,018 ⟶ 6,081:
=={{header|Wren}}==
{{libheader|Wren-date}}
<syntaxhighlight lang="ecmascriptwren">import "./date" for Date
 
System.print("Years between 2008 and 2121 when 25th December falls on Sunday:")
9,476

edits