I have some structures with nested lazy sequences which read from files. When I'm testing I would like to be able to wrap them in a recursive version of doall to make sure all the data is pulled from the files before the files get closed.
(defn doall-recur [s]
(if (seq? s)
(doall (map doall-recur
s))
s))
(use 'clojure.contrib.duck-streams)
(with-open [r1 (reader "test1.txt")
r2 (reader "test2.txt")]
(doall-recur (list (line-seq r2) (line-seq r1))))
Output:
(("This is test2.txt" "") ("This is test1.txt" ""))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With