On Jun 15, 4:58 am, Wrexsoul <d2387...@bsnow.net> wrote:
> 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.

You could also define an explicit end-of-stream object:

  (def end-of-stream (Object.))

  (defn custom-lazy-seq [genfn]
    (take-while #(not= end-of-stream %)
      (repeatedly genfn)))

> The loop/recur style of super-lazy0-seq use seems "closer to
> functional purity" than does an explicitly stateful genfn.

Well, coming from a Haskell background I'd consider using higher-level
functions to be closer to functional purity, but each to their own.

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