Do you have example code that is failing? You should be able to use some of the items you listed as "problems". Try something like this:
(->> (file-seq (io/file "/some/dir")) (map println) (dorun)) AJ On Wed, May 2, 2012 at 12:26 AM, Sean Neilan <s...@seanneilan.com> wrote: > I forgot to mention: > (nth (file-seq (java.io.File. "/DirectoryWithMillionsOfFiles/")) 200000) > works great because nth doesn't realize the sequence! > > For now, I'll look at nth's source code to see how it iterates. > > On Tue, May 1, 2012 at 11:24 PM, Sean Neilan <sneil...@gmail.com> wrote: >> >> Hi, >> >> I'm sure this has been discussed to death but I can't figure it out. >> >> I've got a file-seq sequence from >> (file-seq (java.io.File. "/DirectoryWithMillionsOfFiles/")) that will >> cause an out of memory error if realized. >> >> I want to call a function such as println on every element in the >> sequence. >> >> I understand that naming the sequence will cause it to be realized. >> >> The problems >> >> I can't use map as in (map println (file-seq (java.io.File. >> "/DirectoryWithMillionsOfFiles"))). Map realizes the sequence. >> I can't use for as in (for [x (files)] (println x)). For realizes the >> sequence. >> I can't use dorun because even though dorun doesn't realize the sequence, >> it can't execute a function on every element. >> I can't use loop recur because it also realizes the sequence: (loop [a >> (files) b (first a)] (println b) (recur (rest a) (first a))) >> I can't use refs because even though they provide state, they can't save >> the state of the sequence without realizing the sequence. >> >> My question >> Should I try the new stream library? >> >> Thank you for your time. >> >> -Sean >> > > -- > 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 -- 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