This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-12
Channels
- # announcements (10)
- # babashka (26)
- # beginners (113)
- # calva (75)
- # cider (7)
- # clj-http (1)
- # cljdoc (2)
- # cljfx (3)
- # cljs-dev (13)
- # clojure (79)
- # clojure-europe (21)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-sweden (1)
- # clojure-uk (23)
- # clojureladies (4)
- # clojurescript (26)
- # clojureverse-ops (2)
- # conjure (2)
- # cursive (2)
- # data-science (1)
- # datalog (6)
- # datomic (1)
- # degree9 (2)
- # depstar (4)
- # esprit (3)
- # fulcro (25)
- # introduce-yourself (2)
- # jobs (3)
- # lsp (30)
- # meander (38)
- # missionary (9)
- # nbb (7)
- # news-and-articles (2)
- # off-topic (28)
- # pathom (46)
- # polylith (19)
- # re-frame (4)
- # reitit (2)
- # sci (8)
- # shadow-cljs (23)
- # specter (17)
- # spire (1)
- # tools-deps (16)
- # unrepl (1)
- # xtdb (30)
Hi folks, a question - can a multi-path
share a path between its entries or in other words, can I cascade multi-path
s?
can I need to do some transformation at the top level but also many more that are recursive and would not like to duplicate paths (it's nice that multi-transform
allows me to share but I can't share the recursive path I want to use)
basically I would like to avoid repeating POST-ORDER-VALS
below
(sp/multi-transform (sp/multi-path [(sp/map-key :measurement-definition/type) (sp/terminal-val :measurement-type)]
[(sp/collect-one (sp/must :measurement-definition/legacy)
(sp/must :measurement-definition/api)
(sp/must :measurement-definition/unit))
(sp/must :measurement-definition/unit)
(sp/terminal (fn [current-unit collected-unit] (println "!!!" current-unit collected-unit) (or current-unit collected-unit)))]
[lib.specter/POST-ORDER-VALS lib.specter/MAP-KEY-NAMESPACES (sp/terminal sp/NONE)]
[lib.specter/POST-ORDER-VALS lib.specter/EMPTY-SEQUENCE (sp/terminal sp/NONE)]
[lib.specter/POST-ORDER-VALS sp/MAP-VALS nil? (sp/terminal-val sp/NONE)]))
@richiardiandrea you can combine those three paths into [POST-ORDER-VALS (multi-path [MAP-KEY-NAMESPACES ...] [EMPTY-SEQUENCE ...] [MAP-VALS ...]]
oooo it's that simple lol
not strictly the same if the first path changes what POST-ORDER-VALS
does, but it's probably what you need
oh wait
yeah I tried that and it won't work for sp/collect-one
cause it will do post order and collect twice if I understand correctly
do you have collect-one
inside POST-ORDER-VALS
or your other custom navs?
as written here those three paths don't appear to have any value collection
@nathanmarz well I am collecting a nested key from the top of the tree - that's why I left it out from the recursive navigator
that collect-one
is in an independent path
it needs to be collected at the start of combining those three paths
gotcha, like this?
(sp/multi-transform [(sp/collect-one (sp/must :measurement-definition/legacy) ...)
POST-ORDER-VALS
...
I will try that out, thanks!yeah the problem with putting it at the top of the path is that all the terminal
will be called with two (or more) collected params
I'll leave the duplication in the for now