You're viewing version 1.2.0 of file-seq. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

file-seq

clojure.core

  • (file-seq dir)
A tree seq on java.io.Files

1 Example top

  • ;; first create a Java File object using the file function in
    ;; the clojure.java.io package and use that object to create a file-seq
    ;; then show the first and first 10 members of that seq
    
    user=> (def f (clojure.java.io/file "c:\\clojure-1.2.0"))
    #'user/f
    user=> (def fs (file-seq f))
    #'user/fs
    user=> (first fs)
    #<File c:\clojure-1.2.0>
    user=> (clojure.pprint/pprint (take 10 fs))
    (#<File c:\clojure-1.2.0>
     #<File c:\clojure-1.2.0\.gitignore>
     #<File c:\clojure-1.2.0\build.xml>
     #<File c:\clojure-1.2.0\changes.txt>
     #<File c:\clojure-1.2.0\cl.bat>
     #<File c:\clojure-1.2.0\clojure.jar>
     #<File c:\clojure-1.2.0\doc>
     #<File c:\clojure-1.2.0\doc\clojure>
     #<File c:\clojure-1.2.0\doc\clojure\pprint>
     #<File c:\clojure-1.2.0\doc\clojure\pprint\CommonLispFormat.markdown>)
    user=>
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3911 top

(defn file-seq
  "A tree seq on java.io.Files"
  {:added "1.0"}
  [dir]
    (tree-seq
     (fn [^java.io.File f] (. f (isDirectory)))
     (fn [^java.io.File d] (seq (. d (listFiles))))
     dir))
Vars in clojure.core/file-seq: defn fn seq tree-seq
Used in 1 other vars find-clojure-sources-in-dir

Comments top

No comments for file-seq. Log in to add a comment.