Ramesh, I think the main problem is you're trying to do a recursion over a
tree, so you're blowing a stack if you're not careful, concat is lazy so I
think you're just shifting the problem around, file-seq gets around this by
using tree-seq, which uses 'walk', which is a linearization of the tree.
yes it does..
user> (clojure.pprint/pprint (take 20 (file-seq (clojure.java.io/file"/"
(#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#)
On Mon, May 20, 2013 at 4:43 PM, Jim - FooBar(); wrote:
> well no it doesn't descent into directories...I just tried it...
>
> Jim
>
>
> On 20/
So, I think concat is the problem here. I wish there were recommendation
for other options and reason in the Stacktrace to help me code better!
And file-seq is exactly what I'm looking for :). Thanks all!
Thanks,
ramesh
On Mon, May 20, 2013 at 1:21 PM, Ben Wolfson wrote:
> Basically, you can
well no it doesn't descent into directories...I just tried it...
Jim
On 20/05/13 21:39, Jim - FooBar(); wrote:
actually yes it is! :) I thought file-seq was going down one level
only but looking at the implementation it seems it goes down all
levels...I'm trying it out now
Jim
On 20/05/13 2
actually yes it is! :) I thought file-seq was going down one level only
but looking at the implementation it seems it goes down all levels...I'm
trying it out now
Jim
On 20/05/13 21:31, Gary Trakhman wrote:
Is this not sufficient? file-seq
https://github.com/clojure/clojure/blob/master/src/cl
Is this not sufficient? file-seq
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4478
On Mon, May 20, 2013 at 4:28 PM, Jim - FooBar(); wrote:
> have you considered using mapcat recursively? something like this
> perhaps?
>
> (defn list-all-files [^java.io.File dir]
>
have you considered using mapcat recursively? something like this perhaps?
(defn list-all-files [^java.io.File dir]
(let [children (.listFiles dir)
directories (filter #(.isDirectory %) children)
files (filter #(.isFile %) children)]
(concat files (mapcat list-all-files dire
Basically, you can't use "concat" in a loop like that. You could wrap it in
a (doall ...) to avoid the stack overflow.
On Mon, May 20, 2013 at 1:12 PM, Ramesh wrote:
> Hi all,
>
> I have the following function to list all the files recursively under a
> directory.
>
> (defn list-all-files2 [pat
Hi all,
I have the following function to list all the files recursively under a
directory.
(defn list-all-files2 [path]
(let [basepath (java.io.File. path)]
(loop [origlist [basepath] finallist []]
(if-let [cur (first origlist)]
;This line is not required (if (.isDirectory cur)
(recur (concat (