I am new to Clojure and I have having some issues with iterating data.
The code I have written is below :
(defn save-monthly-targets
"Parse Monthly Targets Data and Save"
[monthlyTargets]
(println "Save Monthly " monthlyTargets)
(if (first monthlyTargets)
(let [month (first monthlyTargets :month)
year (first monthlyTargets :year)
name (first monthlyTargets :name)]
(do
(println "Calling Save Method" month)
(users/set-monthly-target month year name)
(save-monthly-targets (rest monthlyTargets))))))
When I call the function:
(save-monthly-targets [
{:month "May", :year "2021", :target "1200"},
{:month "May", :year "2016", :target "1200"}
])
I get the wrong number of args error in the (if (first monthlyTargets) statement.
The exception is:
ArityException Wrong number of args (2) passed to: core/first clojure.lang.AFn.throwArity
Can someone point what is wrong here?
Thank you very much.