how would I move a piece of a data structure (nested maps and vectors) from one path to another? Seems transform points at a path and changes the value at that path using a function. Would it be a select
followed by a setval
or is there a one-liner?
let me rephrase that because the case is more complex, how would I go from:
{:layout [{:repeat [:a]}
{:delim [" "]}
{:repeat [:b]}],
:apply-for [:odd :even]}
to
{:layout [{:repeat [:a] :apply-for :odd}
{:delim [" "]}
{:repeat [:b] :apply-for :even}]}
where there are as many elements in the :apply-for
vector as there are :repeat
maps in be before structure. So we are matching by index and moving the :odd
and :even
to the corresponding :repeat
mapI get the feeling I might have to select the vector and then do a stateful transform
call where the transform function would pull items from the vector one-by-one, but let me know if there is some better way
@mbjarland use subselect
(let [af (:apply-for data)]
(->> data
(setval [:layout
(subselect
ALL
#(contains? % :repeat)
:apply-for)
]
af)
(setval :apply-for NONE)
))