Skip to content

Instantly share code, notes, and snippets.

@elfenlaid
Last active December 31, 2015 15:28
Show Gist options
  • Save elfenlaid/8006676 to your computer and use it in GitHub Desktop.
Save elfenlaid/8006676 to your computer and use it in GitHub Desktop.
lazy file
(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