This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-19
Channels
- # aws (4)
- # aws-lambda (2)
- # beginners (67)
- # boot (38)
- # cider (32)
- # cljs-dev (12)
- # cljsrn (2)
- # clojars (2)
- # clojure (190)
- # clojure-chicago (1)
- # clojure-dusseldorf (2)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (5)
- # clojure-russia (6)
- # clojure-spec (47)
- # clojure-uk (10)
- # clojurescript (59)
- # cursive (9)
- # data-science (14)
- # datomic (24)
- # devops (16)
- # emacs (8)
- # fulcro (25)
- # graphql (30)
- # hoplon (123)
- # juxt (15)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (6)
- # lumo (9)
- # off-topic (11)
- # om (7)
- # onyx (8)
- # re-frame (14)
- # reagent (5)
- # ring-swagger (5)
- # shadow-cljs (46)
- # spacemacs (41)
- # specter (8)
- # testing (8)
- # unrepl (31)
- # yada (18)
Hi there. How do I do the following transformation with specter:
(let [data {:a {:val 15}
:b {:val 18}}]
(->> data
(map (fn [[k v]]
[k (assoc v :key (name k))]))
(into {})))
i.e. is it possible to capture arguments in transform
path and path them to transformation function?
@kishanov yes, with value collection
(transform [ALL (collect-one FIRST NAME) LAST :key]
(fn [n _] n)
data)
thnx @nathanmarz. Will the same approach work if I want to capture more then 1 value from the path? Ultimately I’m looking for the analog of “Capture groups” in instar
yes, you can capture as many values as you want
each collect
/`collect-one` call produces an extra argument to the transform function, in the order in which they're called