Hey all, how can I duplicate an element in a vector? For example:
[{:a 1} {:b 2 :duplicate 3} {:c 3} {:d 4}] => [{:a 1} {:b 2 :duplicate 3} {:b 2 :duplicate 3} {:b 2 :duplicate 3} {:c 3} {:d 4}]
I was thinking about transform with flatten:
(->> x (transform [ALL (pred :duplicate)] #(repeat (:duplicate %) %)) flatten)
But how can I do it when the vector is in a nested structure?
{:a {:b { :x [...] }}You navigate to the nested object
[ :a :b :x ALL(pred #(contains? % :duplicate))]