Created
April 24, 2012 00:39
-
-
Save jasonmc/2474995 to your computer and use it in GitHub Desktop.
Clojure directory tree builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn buildMap [fl] | |
(cond | |
(.isDirectory fl) | |
(let [subfiles (filter (complement nil?) (map buildMap (.listFiles fl)))] | |
(list (.getAbsolutePath fl) subfiles (reduce + (map last subfiles))) | |
) | |
(.isFile fl) | |
(list (.getAbsolutePath fl) (.length fl)) | |
) | |
) | |
(pprint (buildMap (clojure.java.io/file "/Users/jason/Code/grades"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment