This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-29
Channels
- # aleph (5)
- # announcements (2)
- # bangalore-clj (2)
- # beginners (52)
- # cider (10)
- # cljsrn (1)
- # clojure (160)
- # clojure-dev (24)
- # clojure-europe (3)
- # clojure-france (1)
- # clojure-india (1)
- # clojure-italy (3)
- # clojure-nl (6)
- # clojure-spec (13)
- # clojure-uk (51)
- # clojurescript (45)
- # code-reviews (1)
- # core-async (41)
- # cursive (41)
- # datomic (17)
- # emacs (37)
- # fulcro (42)
- # graphql (7)
- # joker (4)
- # music (1)
- # nrepl (2)
- # off-topic (21)
- # pathom (19)
- # pedestal (12)
- # re-frame (48)
- # reitit (6)
- # rewrite-clj (8)
- # shadow-cljs (41)
- # specter (6)
- # sql (21)
- # tools-deps (8)
- # vim (7)
- # xtdb (27)
I'm trying to use specter to help me generate a map structure that can be converted to an XML string using clojure.data.xml
. With a map function, I can do this:
(mapv (fn [[k v]] {:tag k :content [v]})
{:A 1
:B 2
:C 3})
;; => [{:tag :A, :content [1]} {:tag :B, :content [2]} {:tag :C, :content [3]}]
I tried to do something similar with transform
:
(r/transform
r/ALL
(fn [[k v]] {:tag k :content [v]})
{:A 1
:B 2
:C 3})
;; Execution error (UnsupportedOperationException) at com.rpl.specter.navs/eval18222$fn (navs.cljc:124).
nth not supported on this type: PersistentArrayMap
I don't understand the error that specter is giving me. Is it possible to do what I want to do with specter?@jvtrigueros transform replaces navigated vals and otherwise leaves the structure the same
since you are navigating to key/value pairs, it's expecting you to replace the key/value pairs with key/value pairs
I see
for this particular use case specter isn't really relevant
I understand, I'm using specter to select values in a deeply nested XML tree which worked great. I was trying to use it to generate the XML map datastructure as well.
I can simply do the mapv
operation as the input map is fairly flat.