Jump to content

Check that file exists: Difference between revisions

updated Clojure version
m (→‎{{header|JScript}}: change to JavaScript, works with JScript)
(updated Clojure version)
Line 217:
 
=={{header|Clojure}}==
<lang clojure>
(import '(java.io File))
(doseq fileimport '(list (newjava.io File "input.txt"))
 
(new File "/input.txt"))
(defn kind [filename]
(when (not (. file exists)) (println file "is missing"))
(let [f (File. filename)]
(when (. file isDirectory) (println file "is a directory!")))
(cond
(doseq file (list (new.isFile f) File "docsfile")
(new.isDirectory Filef) "/docsdirectory"))
(when (not (.exists file exists)f) (println file "isother" missing"))
:else "(non-existent)" )))
(when (. file isDirectory) (println file "is a directory!"))
 
(defn look-for [filename]
(println filename ":" (kind filename)))
 
(look-for "file.txt")
(look-for "/file.txt")
(look-for "docs")
(look-for "/docs")
</lang>
 
=={{header|Common Lisp}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.