Clojure - Is it possible to increment a variable within a doseq statement?
问题 I am trying to iterate over a list of files in a given directory, and add an incrementing variable i = {1,2,3.....} to their names. Here is the code I have for iterating through the files and changing each file's name: (defn addCounterToExtIn [d] (def i 0) (doseq [f (.listFiles (file d)) ] ; make a sequence of all files in d (if (and (not (.isDirectory f)) ; if file is not a directry and (= '(\. \i \n) (take-last 3 (.getName f))) ) ; if it ends with .in (fs/rename f (str d '/ i (.getName f)))