I'm trying to grab 5 lines by their line numbers from a large (> 1GB) file with Clojure.
So far I've got: (defn multi-nth [values indices] (map (partial nth values) indices)) (defn read-lines [file indices] (with-open [rdr (clojure.java.io/reader file)] (let [lines (line-seq rdr)] (multi-nth lines indices)))) Now, (read-lines "my-file" [0]) works without a problem. However, passing in [0 1] gives me the following error: "java.lang.RuntimeException: java.io.IOException: Stream closed" It seems that the stream is being closed before I can read the second line from the file. Interestingly, if I manually pull out a line from the file with something like `(nth lines 200)`, the `multi-nth` call works for all values <= 200. Any idea what's going on? PS This question is on SO if someone wants points: http://stackoverflow.com/questions/11995807/lazily-extract-lines-from-large-file -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en