On Jun 14, 2009, at 12:53 PM, James Reeves 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))))


I've done this too. It works great if you're certain the function  
being called by repeatedly will never return nil until the stream is  
exhausted. Many streams seem to work like that in practice despite the  
caveat and I find it nicer looking than an explicit test.

—
Daniel Lyons
http://www.storytotell.org -- Tell It!


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to