Fork me on GitHub
#specter
<
2016-08-11
>
borkdude10:08:58

It brings me to the question how you prune a map in specter

borkdude10:08:40

like {:a 1, :b 2, :c 3} => {:a 1}, it must be possible, but I haven't used this yet

borkdude10:08:56

I was thinking something with multi-path and filterer?

borkdude12:08:57

Ah, the question is even different than I understood it. I thought he wanted {:a 1, :b 2, :c {:d 3}} leaving the structure intact

nathanmarz13:08:34

@borkdude: submap is the specter analogue to select-keys

borkdude13:08:48

going to try it

nathanmarz13:08:59

(into {} (traverse (multi-path (submap [:a :b]) [:c (submap [:d])]) {:a 1 :b 2 :c {:d 3}}))

nathanmarz13:08:47

could make a function that converts [:a :b [:c :d]] to that path

borkdude13:08:23

(prune m [:a :b [:c :d]])

nathanmarz13:08:53

a better way is to capture the idea of "nested submaps" as a navigator

nathanmarz13:08:19

(into {} (traverse (nested-submaps :a :b [:c :d]) m))