This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-13
Channels
- # beginners (99)
- # boot (2)
- # boot-dev (4)
- # chestnut (2)
- # cider (75)
- # clara (43)
- # cljs-dev (1)
- # cljsjs (6)
- # cljsrn (4)
- # clojars (2)
- # clojure (76)
- # clojure-brasil (1)
- # clojure-france (1)
- # clojure-italy (2)
- # clojure-spec (30)
- # clojure-uk (4)
- # clojurescript (39)
- # core-async (1)
- # core-logic (2)
- # cursive (1)
- # data-science (7)
- # datomic (14)
- # docker (12)
- # emacs (6)
- # fulcro (69)
- # garden (4)
- # hoplon (7)
- # jobs-discuss (46)
- # leiningen (3)
- # lumo (3)
- # off-topic (12)
- # om (2)
- # parinfer (12)
- # perun (9)
- # re-frame (44)
- # reagent (6)
- # rum (1)
- # shadow-cljs (73)
- # specter (5)
- # unrepl (10)
- # vim (2)
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)
))