Fork me on GitHub
#specter
<
2024-04-11
>
Chris Chambers10:04:08

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))