Fork me on GitHub
#specter
<
2016-10-25
>
nlessa17:10:28

Hi, How could I solve in specter this problem? Given a key (eg: :e) located in an undetermined nested level of a map return the map with only the keys that compose the path to reach it.

For example: 
{:a 1 :b {:c 2 :d {:e 3 :f 4} :g {:e 5 :h 8}}}

 --> {:b {:d {:e 3} :g {:e 5}}}

nathanmarz20:10:16

@nlessa two ways to go about it

nathanmarz20:10:46

first is to use select with a recursive path + value collection to get the sequence of paths to your desired key/values. Then construct the nested map manually

nathanmarz20:10:13

second is to make a new navigator like ALL that removes values when NONE is returned on transformation

nathanmarz20:10:27

with that you could solve your use case with a single transform call