Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noisesmith/c2b44cd1282fa46453fcc61577589809 to your computer and use it in GitHub Desktop.
Save noisesmith/c2b44cd1282fa46453fcc61577589809 to your computer and use it in GitHub Desktop.
get all the clojure forms from a file
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