This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-17
Channels
- # announcements (2)
- # asami (3)
- # babashka (30)
- # beginners (23)
- # calva (28)
- # cider (3)
- # clj-kondo (16)
- # clj-on-windows (7)
- # cljs-dev (7)
- # clojure (47)
- # clojure-austin (3)
- # clojure-europe (25)
- # clojure-gamedev (3)
- # clojure-greece (1)
- # clojure-nl (1)
- # clojure-uk (3)
- # clojurescript (54)
- # community-development (24)
- # conjure (16)
- # duct (1)
- # emacs (8)
- # events (1)
- # figwheel-main (4)
- # fulcro (13)
- # gratitude (20)
- # helix (3)
- # honeysql (8)
- # hyperfiddle (12)
- # introduce-yourself (1)
- # jobs (6)
- # lambdaisland (1)
- # lsp (35)
- # malli (1)
- # meander (27)
- # minecraft (11)
- # off-topic (12)
- # pathom (1)
- # portal (11)
- # releases (1)
- # remote-jobs (1)
- # ring (11)
- # sci (1)
- # shadow-cljs (53)
- # specter (5)
- # xtdb (20)
OK, I’m trying Specter out, and I can’t figure out how to make this transform happen. I’ve got a two-level map containing some vecs of numbers, and I want to replace the middle level with the set intersection of the vecs. How do I make:
(def example {"top1" {"mid1" [1 2 3]
"mid2" [2 3 4]
"mid3" [3 4 5]}
"top2" {"mid4" [1 2 3]
"mid5" [2 3 4]
"mid6" [3 4 5]}})
turn into something like:
{"top1" #{3}
"top2" #{3}}
?And how would I filter out some of the “mid*” keys if necessary?
Closest I’ve come so far is something like:
(transform [MAP-VALS]
(fn [m]
(->> m
(select MAP-VALS)
(reduce (fn rf [s v]
(set/intersection (set s) (set v))))))
example)
but it takes two stages and feels un-Specter-y