-
Notifications
You must be signed in to change notification settings - Fork 0
/
19.clj
64 lines (43 loc) · 1.03 KB
/
19.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(defn days []
(cycle [:mon :tues :weds :thurs :fri :sat :sun]))
(defn leap-year? [year]
(cond (= (rem year 400)
0)
true
;
(= (rem year 100)
0)
false
;
(= (rem year 4)
0)
true
;
:else
false))
(defn days-in-month [month year]
(cond (= month :sept) 30
(= month :april) 30
(= month :june) 30
(= month :nov) 30
(= month :feb) (if (leap-year? year)
29
28)
;
:else 31))
(def months [:jan :feb :march :april :may :june :july :aug :sept :oct :nov :dec] )
(defn dates []
(for [year (range 1900 2001)
month months
date (range 1 (inc (days-in-month month year)))]
[date month year]))
(def daydates (map cons (days) (dates)))
;(println (take 365 daydates))
(time
(println
(count
(for [[day date month year] daydates
:when (> year 1900)
:when (and (= day :sun)
(= date 1))]
[day date month year]))))