This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-08
Channels
- # announcements (8)
- # aws (2)
- # babashka (11)
- # babashka-sci-dev (39)
- # beginners (62)
- # calva (5)
- # cider (1)
- # clj-kondo (50)
- # cljdoc (2)
- # cljs-dev (6)
- # clojure (52)
- # clojure-austin (22)
- # clojure-czech (13)
- # clojure-europe (88)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (6)
- # clojuredesign-podcast (13)
- # clojurescript (45)
- # community-development (3)
- # core-typed (31)
- # cursive (12)
- # datahike (2)
- # datalevin (7)
- # datomic (5)
- # events (1)
- # exercism (11)
- # fulcro (27)
- # gratitude (1)
- # holy-lambda (3)
- # hoplon (2)
- # introduce-yourself (2)
- # jobs (1)
- # lambdaisland (3)
- # lsp (110)
- # malli (2)
- # meander (4)
- # music (2)
- # off-topic (50)
- # overtone (1)
- # pathom (13)
- # polylith (26)
- # re-frame (4)
- # releases (2)
- # rewrite-clj (3)
- # ring (12)
- # shadow-cljs (20)
- # specter (4)
- # tools-deps (8)
- # xtdb (40)
would it be possible to do the following sequence of multi-transform
& select-one
in one step?
that would allow me to package up this transform/select operation as a path (instead of a function), so it can be combined with further processing.
(->> {:cols [10 20 30]
:rows [[1 2 3]
[4 5 6]]}
(sp/multi-transform
[(collect-one :cols)
:rows ALL (terminal (partial mapv +))])
(sp/select-one :rows))
=> [[11 22 33] [14 25 36]]
equivalent clojure code:
(->> {:cols [10 20 30]
:rows [[1 2 3]
[4 5 6]]}
((fn [{:keys [cols rows]}]
(mapv
(fn [cells]
(mapv + cells cols))
rows))))
=> [[11 22 33] [14 25 36]]
in more abstract terms, i want to
1. select from the input structure
2. transform the selected part
3. combine the transformed part with another selected and transformed part of the original structure
i can of course do all this in a regular clojure function, which i can compose with further select/transform operations via view
, but do i have to?
i have the feeling, that im missing some navigator, so i can do this kind of multi collection map
operation.
both view
and transformed
doesn't receive the collected values.
terminal
/ vterminal
does receive collected values, but also the currently navigated value too, so i have to wrap clojure.core
functions to ignore that last argument.
collected?
receives all collected values, both individually or as a single vector, but it's return value is not used to replace the value, we are currently navigated to.