This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-19
Channels
- # aws (2)
- # babashka (4)
- # babashka-sci-dev (7)
- # beginners (92)
- # biff (7)
- # calva (64)
- # cider (2)
- # cljsrn (14)
- # clojure (8)
- # clojure-australia (5)
- # clojure-europe (14)
- # clojure-norway (8)
- # clojure-spec (36)
- # clojurescript (19)
- # component (15)
- # cursive (1)
- # data-science (6)
- # girouette (5)
- # hyperfiddle (3)
- # juxt (5)
- # leiningen (10)
- # lsp (7)
- # malli (12)
- # nbb (90)
- # polylith (1)
- # portal (11)
- # rdf (7)
- # reagent (6)
- # reitit (40)
- # remote-jobs (1)
- # shadow-cljs (21)
- # specter (5)
- # squint (83)
- # tools-deps (17)
- # vim (7)
Q: I always get stuck trying to do a transform with indexes i.e. like map-indexed. I can’t use INDEXED-VALS because I’m not trying to change ordering. What is the idiom here?
Hi, I am trying to transform
some data, encountered some problem.
(transform [(walker (fn [x]
(when (instance? java.util.Map$Entry x)
(let [[k v] x]
(do (prn [k v])
(when (string? v)
(re-matches #"\d+" v)
)
))))) (nthpath 1)]
(fn [v] (Integer/parseInt v 10))
{:ind {:hanging "1134" :left "1134"}}
)
;; => {:ind {:hanging "1134" :left "1134"}}
;; Expected result:
;; {:ind {:hanging 1134 :left 1134}}
Why transform
not modify the value?
Should I use recursive-path
to do the work?dev> (select (walker (fn [x] (println x (type x)))) {:a 1})
{:a 1} clojure.lang.PersistentArrayMap
[:a 1] clojure.lang.MapEntry
:a clojure.lang.Keyword
1 java.lang.Long
;; => []
dev> (transform (walker (fn [x] (println x (type x)))) (constantly nil) {:a 1})
{:a 1} clojure.lang.PersistentArrayMap
[:a 1] clojure.lang.PersistentVector
:a clojure.lang.Keyword
1 java.lang.Long
;; => {:a 1}
looks like a bug