Last active
December 31, 2015 15:28
-
-
Save elfenlaid/8006676 to your computer and use it in GitHub Desktop.
lazy file
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 lazy-open [file] | |
(letfn [(helper [rdr] | |
(lazy-seq | |
(if-let [line (.readLine rdr)] | |
(cons line (helper rdr)) | |
(do (.close rdr) (println "closed") nil))))]) | |
(do (println "opening") | |
(helper (clojure.java.io/reader file)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment