I’m trying to figure out a way to add an object to a vector map.
(defstruct item :name)
(def itemList [])
(defn add-item [db & item]
(into db item))
(defn get-records[]
(doseq [i (range 0 10 1)]
(add-records itemList (struct item "test")
))
In the end of the loop I want itemList to contain 10 objects. Any help would very much appriciated
Clojure is a functional programming language and all of its main data structures are immutable and persistent. That also includes vector.
Your example needs managing a state. Clojure provides several abstractions for this, out of which, I think atoms fit your use case best.