Day of the week: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,896: | Line 1,896: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
|||
isdefined(:Date) || using Dates |
|||
<lang julia>using Base.Dates |
|||
⚫ | |||
hi = 2121 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
println("Years |
println("Years from $lo to $hi having Christmas on Sunday: ") |
||
foreach(println, year.(xmas))</lang> |
|||
for y in smas |
|||
println(" ", Dates.year(y)) |
|||
end |
|||
</lang> |
|||
This code uses the <code>Dates</code> module, which is being incorporated into Julian's standard library with the current development version (<tt>0.4</tt>). I've used <code>isdefined</code> to make this code good for the current stable version (<tt>0.3</tt>) as well as for future releases. If <code>Dates</code> is not installed on your instance of Julian try <code>Pkg.add("Dates")</code> from the <tt>REPL</tt>. |
|||
{{out}} |
{{out}} |
||
<pre>Years |
<pre>Years from 2008 to 2121 having Christmas on Sunday: |
||
2011 |
|||
2016 |
|||
2022 |
|||
2033 |
|||
2039 |
|||
2044 |
|||
2050 |
|||
2061 |
|||
2067 |
|||
2072 |
|||
2078 |
|||
2089 |
|||
2095 |
|||
2101 |
|||
2107 |
|||
2112 |
|||
2118</pre> |
|||
</pre> |
|||
=={{header|K}}== |
=={{header|K}}== |