Say I have a set of cards:
(def coll #{{:name "foo"} {:name "bar"}})
I need a function that will add an id (a unique number in order) to each card element in the collection. i.e.
#{{:id 1 :name "foo"} {:id 2 :name "bar"}}
The following DOES NOT WORK, but this is the line of thinking that I now have.
(defn add-unique-id [coll]
(map assoc :id (iterate inc 0) coll))
Thanks in advance...
source
share