Fork me on GitHub
Joshua Suskalo20:06:59

Is there a way to perform a select that uses values from a selection to navigate? Like to select down one path, and then use the selected value to navigate down another?

Joshua Suskalo21:06:49

Seems like collected? is what I was looking for.

Joshua Suskalo21:06:29

Actually, not quite. I'd like to be able to refer to both the collected? values and the structure.

Joshua Suskalo21:06:10

Say for example I want to query this structure:

{:guild {:a {:members ["1234"]}}
 :members {"1234" 1}}
What I'd like to do is select along [:guild :a :members ALL] and then use those values to then do [:members the-key] on the original structure.

Joshua Suskalo22:06:12

It looks like this can be done with some effort by using the transformed navigator

Joshua Suskalo22:06:59

In this particular case, it would be done in this manner:

(select-one [(transformed [(collect :guilds MAP-VALS :members ALL)
                          #(select-keys %2 %1))
             :members MAP-VALS]