This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-11
Channels
- # announcements (2)
- # babashka (31)
- # beginners (31)
- # calva (30)
- # cider (23)
- # clerk (1)
- # clojure (46)
- # clojure-austin (5)
- # clojure-brasil (1)
- # clojure-europe (47)
- # clojure-nl (1)
- # clojure-norway (72)
- # clojure-uk (2)
- # clojurescript (39)
- # conjure (1)
- # cursive (16)
- # data-science (1)
- # datomic (35)
- # dev-tooling (4)
- # events (5)
- # introduce-yourself (2)
- # jobs-discuss (5)
- # missionary (3)
- # polylith (11)
- # releases (4)
- # scittle (4)
- # shadow-cljs (18)
- # spacemacs (16)
- # specter (2)
- # squint (27)
- # xtdb (6)
Hey there - I’m having trouble finding an example of this in the documentation. I have a map of various criterium test results (e.g. {:test-name1, quick-benchmark-results, ...}
, and I can easily select out the :mean
for each using specter, but I really want them zipped with the corresponding key. Is there a trick/idiom for doing this? I presume it’s fairly common to want to “juxt” multiple parts of a nested data structure and I’m just not spotting it.
A minimal example:
(def eg {:test1 {:a {:b 1 :c (range 1000)}
:mean [:interesting-data [:extra :stuff]]}
:test2 {:a {:b 2 :c (range 1000 2000)}
:mean [:also-interesting-data [:extra :stuff]]}})
desired output:
{:test1 :interesting-data :test2 :also-interesting-data}
This is the best I can get so far, but I’m guessing I can do this entirely from within specter:
(zipmap (keys eg) (select [MAP-VALS :mean FIRST] eg))