Thanks a lot .. really good

On Oct 6, 5:39 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote:
> On Wed, Oct 6, 2010 at 08:49, Abraham <vincent....@gmail.com> wrote:
> > Dear All ,
>
> > I wanted to list  the files of a folder , if a folder within , then it
> > should list the files of that folder and so on.. ie recursively list
> > files of folders
>
> > I tried with recur & loop and could not do it . Then i searched the
> > internet for the code , i got the code , but i am not able to
> > understand it , what is -> for ?
> > following is the code .
>
> -> is a macro. It rewrites the code it's invoked on before it is compiled:
>
> (-> dirpath File. file-seq)
> becomes:
> (file-seq (File. dirpath))
>
> You can think of -> threading its first argument through a list of
> functions. So we give dirpath to File. then we give the result of that to
> file-seq.
>
>
>
> > ; prints all files
> > (import 'java.io.File)
> > (defn walk [dirpath]
> >  (doseq [file (-> dirpath File. file-seq)]
> >     (println (.getPath file)  )))
>
> This doesn't do what you said you wanted to do above: list all files,
> recursively. It just lists the files contained directly in dirpath.
>
>
>
> > can anybody help to do with using recur / loop so to know how to use
> > recur or loop.
>
> loop/recur allow one to describe iterative computations in a recursive
> style. Iterative computations don't consume stack space.
>
> Listing files recursively is a tree recursion. A tree recursion is not an
> iterative process. loop/recur won't help you there. You'll need to use real
> stack-consuming recursion.
>
> Here's an example that will produce a recursive list of all files in or
> below a given directory:
>
> http://gist.github.com/613279
>
> Note, however, that the recursion is indirect, since walk calls mapcat,
> which calls walk again.
>
> // Ben
>
> Thanks in advance
>
>
>
> > Abraham
>
> > --
> > 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<clojure%2bunsubscr...@googlegroups.com 
> > >
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

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