Thanks everyone! I think I figured it out. Being new to Clojure, I wasn't
really considering that I was passing an anonymous function and wasn't
thinking about recursion. Coming fom an Object Oriented background,
properly forming functions is a bit new to me. Thanks for all the pointers!
I
On 12 March 2014 00:06, Brandon Barret wrote:
>
> (defn list-paths [directory]
> (println "Files in " (.getName directory))
> (doseq [f (.listFiles directory)]
> (if (.isDirectory f)
> (print "directory: ")
> (print "- "))
> (println (.getName f)
> (fn clj-check [d
Jarrod,
Thanks! I have heard of fs. Since I am new to Clojure, I was resistant to
try it, but am going to look into it more tonight. Thanks!
Brandon
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@g
No problem, happy to help. Here is one way you might write the above with
fs. I didn't check this I just typed it out so there may be a few tiny
bugs.
(defn jar? [filename]
(if (= (fs/extension filename) "jar")
true
false))
(defn list-paths [path-str]
(println "Files in " path-str
Hey Brandon,
I had a really simple blog post about reading a directory of files that I
never published, I updated it and hopefully it can help:
http://jarrodswart.com/clojure-like-im-five-working-with-files/
Best,
Jarrod
--
You received this message because you are subscribed to the Google
Gr
Sean,
I am getting closer. Sorry about that. Here is my (rudimentary) code. My
goal is to print the contents of a directory, and from that, print one of
two things based on the results ( an if/then, if you will). I am running
into a few problems though.
(defn list-paths [directory]
(p
Brandon Barret writes:
> Hello all,
>
> I am working on a program that needs to list all the files in a directory.
> I have read that Clojure doesn't yet have great support for this kind of
> task, and that it is better to import java.io.File to your namespace in
> order to use some of it
Hard to tell what your problem is with so little information to go on.
Here's the code we use to get a directory listing:
(defn- wildcard-filter
"Given a regex, return a FilenameFilter that matches."
[re]
(reify java.io.FilenameFilter
(accept [_ dir name] (not (nil? (re-find re name