Created
September 28, 2011 22:24
-
-
Save omasanori/1249422 to your computer and use it in GitHub Desktop.
A hobby implementation to calculate leap years.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn leap-year? | |
"Returns true if x is leap year, false otherwise." | |
[x] | |
(or (zero? (rem x 400)) | |
(and (zero? (rem x 4)) | |
(not (zero? (rem x 100)))))) | |
(defn leap-years | |
"Returns a lazy seq of leap years." | |
[] | |
(filter leap-year? (drop 1582 (range)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment