Sean, > 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 problem is not in "realizing" the sequence, but in "holding on to the head". Naming the sequence using `def` or `'let` will indeed hold on to the head, but I don't see why loop/recur can't solve your problem. Something like this should work - (loop [fs (file-seq (java.io.File. "/DirectoryWithMillionsOfFiles/"))] (println (first fs)) (recur (rest fs))) Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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