Re: Lazily extract lines from large file

2012-08-22 Thread Stephen Compall
On Aug 17, 2012 4:53 PM, David Jacobs da...@wit.io wrote: Okay that's great. Thanks, you guys. Was read-lines only holding onto the head of the line seq because I bound it in the let statement? No; (partial nth values) holds on to values, and map holds on to the function you give it. Omitting

Re: Lazily extract lines from large file

2012-08-18 Thread Ben Smith-Mannschott
. 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

Re: Lazily extract lines from large file

2012-08-17 Thread Ben Smith-Mannschott
points: http://stackoverflow.com/questions/11995807/lazily-extract-lines-from-large-file The lazyness of map is biting you. The result of read-lines will not have been fully realized before the file is closed. Also, calling nth repeatedly is not going to do wonders for efficiency. Try

Re: Lazily extract lines from large file

2012-08-17 Thread David Jacobs
. 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

Lazily extract lines from large file

2012-08-16 Thread David Jacobs
. 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

Re: Lazily extract lines from large file

2012-08-16 Thread Lars Nilsson
On Thu, Aug 16, 2012 at 5:47 PM, David Jacobs da...@wit.io wrote: 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