Created
May 8, 2016 14:39
-
-
Save noisesmith/c2b44cd1282fa46453fcc61577589809 to your computer and use it in GitHub Desktop.
get all the clojure forms from a file
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
user=> (spit "test.edn" (pr-str {:a 0 :b 1 :c 2} 42)) | |
nil | |
user=> (slurp "test.edn") | |
"{:a 0, :b 1, :c 2} 42" | |
user=> (let [r (java.io.PushbackReader. (io/reader "test.edn"))] | |
(take-while #(not= ::done %) | |
(repeatedly #(try (edn/read r) | |
(catch Exception _ ::done))))) | |
({:a 0, :b 1, :c 2} 42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment