This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-31
Channels
- # aws-lambda (4)
- # beginners (152)
- # boot (19)
- # cider (45)
- # cljs-dev (14)
- # clojure (54)
- # clojure-dev (33)
- # clojure-greece (11)
- # clojure-italy (4)
- # clojure-nl (8)
- # clojure-norway (2)
- # clojure-russia (6)
- # clojure-sg (1)
- # clojure-spec (1)
- # clojure-uk (40)
- # clojure-ukraine (5)
- # clojurescript (40)
- # community-development (13)
- # component (8)
- # core-async (3)
- # cursive (25)
- # data-science (11)
- # datomic (13)
- # duct (1)
- # emacs (2)
- # events (16)
- # figwheel (3)
- # fulcro (53)
- # graphql (2)
- # jobs (5)
- # jobs-rus (1)
- # juxt (10)
- # leiningen (4)
- # off-topic (82)
- # other-languages (5)
- # portkey (3)
- # protorepl (13)
- # re-frame (22)
- # reagent (15)
- # ring-swagger (4)
- # shadow-cljs (69)
- # spacemacs (7)
- # specter (16)
- # sql (13)
- # vim (5)
- # yada (2)
is there a something like a ‘move’ macro/operation? I’m picking my way through the use of recursive-path, etc. Basically, I’ve a use case where I need to find a node in a tree, save its current value, delete it from its current location, find a target node, then insert the saved node before or after the target. Once I get the recursive locator stuff working, it seems like I’d need a select and two transforms, or a select and a multi-transform, is that more or less correct?
best way to do something like that would be combining multi-transform
and collect-one
depends on the use case though, some could require zippers
would need to see specifically what you're trying to do
hi @nathanmarz sure, here’s a simplified example
(def fakeform {:formdef {:form/id 1
:form/groups [{:group/id 2
:group/type :page
:group/fields [{:field/id 3
:field/name :fieldone}
{:field/id 4
:field/name :fieldtwo}
{:field/id 5
:field/name :fieldthree}]
:group/subgroups [{:group/id 6
:group/type :section
:group/fields [{:field/id 7
:field/name :fieldfour}]}]}]}})
I’d like to approach simple transforms like “move the map identified by :field/id 3
after the one identified by :field/id 4
” (which I can do with a srange/reverse, etc) as well as more arbitrarily complex ones like “move the map identified by :field/id 3
after the one identified by :field/id 7
” in a consistent manner@eoliphant you can do this with a helper path that navigates you to a zipper pointing to the desired node
(point-to 3)
then you could do (select-any [(point-to 3) zip/NODE] fakeform)
to get the value for 3
(setval [(point-to 3) zip/NODE-SEQ] [] fakeform)
to remove 3
and (setval [(point-to 7] zip/INNER-RIGHT] [value-for-3] fakeform)
to finish the move
actually you could combine the retrieval of 3's value with removal using replace-in