Created
December 29, 2020 18:50
-
-
Save ezmiller/e642960d4653f0c8a54ca15d2fd5e041 to your computer and use it in GitHub Desktop.
Clojure lazy sequence of days from 1970-01-01 using java.time
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
;; Creates a lazy sequence of days from 1970-01-01 | |
(defn days-from-epoch | |
([] (days-from-epoch (java.time.LocalDate/parse "1970-01-01"))) | |
([local-date] | |
(prn local-date) | |
(lazy-seq (cons local-date (days-from-epoch (.plusDays local-date 1)))))) | |
(take 2 (days-from-epoch)) | |
;; => (#time/date "1970-01-01" #time/date "1970-01-02") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment