Skip to content

Instantly share code, notes, and snippets.

@jasonmc
Created April 24, 2012 00:39
Show Gist options
  • Save jasonmc/2474995 to your computer and use it in GitHub Desktop.
Save jasonmc/2474995 to your computer and use it in GitHub Desktop.
Clojure directory tree builder
(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