On Jun 14, 3:21 am, Wrexsoul <d2387...@bsnow.net> wrote:
> It lets you write the generator in a style similar to loop/recur, and
> generally in half the code. And, it demonstrates the kinds of things
> you can do with macros.

Ahh, I see. That could be useful under some circumstances. However,
most Clojure functions that deal with lists return lazy seqs, so a lot
of the time you don't need to call lazy-seq directly.

For instance, lets say I want to return a lazy list of all the lines
in all the files in a directory tree:

  (use '(clojure.contrib java-utils
                         duck-streams))

  (defn all-line-seq [dir]
    (mapcat read-lines (file-seq (file dir))))

Since file-seq, read-lines and mapcat all lazy, my final result is
lazy as well.

> Is file-seq recursive? I'd figured it just returned the flat contents
> of a directory.

Yep, it's recursive. If you just want the flat list you could just use
the .listFiles method, which I guess is why there isn't an explicit
function for it in clojure.core.

- 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