Hi all, At the risk of being labelled "the guy who always whines about line-seq", I'm whining about line-seq again. I hit some surprising behaviour stemming from the fact that line-seq isn't fully lazy:
(defn line-seq "Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader." [#^java.io.BufferedReader rdr] (when-let [line (.readLine rdr)] (cons line (lazy-seq (line-seq rdr))))) This implementation is fully lazy: (defn line-seq [rdr] (lazy-seq (when-let [line (.readLine rdr)] (cons line (line-seq rdr))))) but doesn't return nil on an empty sequence, which I think is why line-seq was changed in the first place (commit efc54c000445f8b3d8d2e75d560fa02397951598). It seems that there's an inherent trade-off between wanting to return nil for an empty sequence and wanting to be fully lazy, so I'm not sure of the best way of achieving both objectives. I just thought I'd raise the issue in case someone brighter than me has any good ideas :) Cheers, Mark -- Mark Triggs <mark.h.tri...@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