Fork me on GitHub
#specter
<
2018-08-17
>
mmer10:08:31

Simple question - I want to collect a set of keys from a nested map (but not all the keys - is there a simple way to do this?

nathanmarz12:08:47

@mmer if you just want to filter by a predicate you can do (select [MAP-KEYS even?] {1 :a 2 :b 3 :c 4 :d}) ;; => [2 4]

mmer13:08:38

As always happens with this - getting back into using after a while can be brain twisting - I want to do a conditional collect. I want to collect something based on a child map containing a certain key

mmer13:08:36

Also is there an easy way to select a map entry that has a certain key no matter where in a deeply nested data structure it is?

nathanmarz13:08:07

@mmer do you have specific examples of what you're trying to do? It varies depending on the specifics

mmer14:08:37

I am working over a yaml datastructure. I would like collect the name of the yaml item if the structure contains an item called "tag" , I also need the content of the tag.

mmer14:08:59

Interesting side point - until you asked this question I was unaware of the nastiness of the extra vectors as inmost case specter just did what I expected! --fantastic. Just these odd cases

nathanmarz14:08:03

@mmer is that map in the input supposed to be a vector?

nathanmarz14:08:29

and by nested anywhere inside, you mean any one of those inner vectors could repeat the top-level structure?

mmer14:08:52

The input structure could be contained anywhere in a larger structure and yes that should be a map - sorry

nathanmarz14:08:20

@mmer do you have an example of a more deeply nested structure?

mmer14:08:51

Not sure I can share that - don't worry about it I will keep going. I am making progress in other areas. Thanks.