Day of the week: Difference between revisions

Content added Content deleted
Line 1,231: Line 1,231:
Utilizing Java interop
Utilizing Java interop


<syntaxhighlight lang="clojure">
<syntaxhighlight lang="clojure">(import '[java.util GregorianCalendar])
(import '(java.util GregorianCalendar))
(defn yuletide [start end]
(defn yuletide [start end]
(->> (range start (inc end))
(filter #(= (. (new GregorianCalendar %
(filter #(= GregorianCalendar/SUNDAY
(. GregorianCalendar DECEMBER) 25) get (. GregorianCalendar DAY_OF_WEEK))
(.get (GregorianCalendar. % GregorianCalendar/DECEMBER 25)
(. GregorianCalendar SUNDAY)) (range start (inc end))))
GregorianCalendar/DAY_OF_WEEK)))))


(yuletide 2008 2121)
(println (yuletide 2008 2121))
</syntaxhighlight>
</syntaxhighlight>

{{out}}
<pre>(2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118)</pre>
<pre>(2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118)</pre>