specter

itaied 2023-07-20T14:07:12.607849Z

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 [...] }}

mmer 2023-07-20T16:51:05.122299Z

You navigate to the nested object

[ :a :b :x  ALL(pred #(contains? % :duplicate))]