On Jun 14, 2:53 pm, James Reeves <weavejes...@googlemail.com> wrote: > On Jun 14, 6:32 pm, Wrexsoul <d2387...@bsnow.net> wrote: > > > I wrote super-lazy-seq because repeatedly can't generate a finite > > sequence. It just spat out > > > (File1 File2 File3 File4 nil nil nil nil nil nil nil ... > > Well, you could wrap it in take-while: > > (defn custom-lazy-seq [stream] > (take-while (complement nil?) > (repeatedly #(next-item-in-seq stream))))
Eh. That didn't occur to me. It could be combined with the meta-nil trick, too: (defn custom-lazy-seq [genfn] (map #(first %) (take-while (complement nil?) (repeatedly genfn)))) where the genfn returns nil for no-next-item and [item] otherwise. Of course, super-lazy-seq: a) does the wrapping AND unwrapping for you b) manages the rebinding each iteration for you, transparently and c) works just as well. The loop/recur style of super-lazy0-seq use seems "closer to functional purity" than does an explicitly stateful genfn. One thing is becoming clear: in clojure, there's generally more than one way to do it. Whatever "it" is. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---