Created
January 15, 2012 07:59
-
-
Save biesnecker/1614995 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(import '(org.joda.time LocalDate)) | |
(defn today [] (LocalDate.)) | |
;; basic functions to increment or decrement a date | |
(defn inc-date [#^LocalDate ds] (.plusDays ds 1)) | |
(defn dec-date [#^LocalDate ds] (.minusDays ds 1)) | |
;; generate infinite streams of LocalDate objects starting with start-ds | |
(defn inc-date-stream [#^LocalDate start-ds] (iterate inc-date start-ds)) | |
(defn dec-date-stream [#^LocalDate start-ds] (iterate dec-date start-ds)) | |
This file contains hidden or 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 weekend? [#^LocalDate ds] (> (.get (.dayOfWeek ds)) 5)) | |
(take 50 (filter weekend? (inc-date-stream (today)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment