I am having trouble iterating over the function arguments passed in to the following function.
(defn iterateDates
[& dates]
(let [ukFormatter (java.time.format.DateTimeFormatter/ofPattern "dd-MM-yyyy")]
(for [i [dates]]
(java.time.LocalDate/parse i ukFormatter))))
(iterateDates "09-10-2019" "10-10-2019" "11-10-2019")
This however when called, returns the following error:
Error printing return value (ClassCastException) at clojure.core/getOldestDate$iter$fn$fn (core.clj:96).
clojure.lang.ArraySeq cannot be cast to java.lang.CharSequence
I am not sure on how to iterate over the arguments passed in and take each element as a separate value which can then be passed to another function.
My goal ultimately with the code will be to compare a list of dates and find the oldest date in there. This code just tries to parse each argument as a date.
(for [i [dates)]. Please post the actual code. Also you have the body of theforwrapped in two pairs of parenthesis, which will cause the return ofparseto be called as a function. Is that your intent? Also, please post the full stack trace. On first brush, that error doesn't seem to stem from this code.(for [i dates]. I don't know how that would cause that error, but you're passing the entiredatessequence toparseat once with how you have it now.