Fork me on GitHub
#meander
<
2024-05-27
>
Tommi Martin05:05:56

How would you solve a situation in meander where you have to use regex do the following steps? 1. Find multiple keywords in a map based on regex? (pattern X_from_Y) 2. Iterate the submap values and collect their keys and name from their values. 3. Output the results

{:random-values []
 :blue_from_red {:red1 {:name "red-sample-1}
                 :red2 {:name "red-sample-2}}
 :blue_from_black {:black1 {:name "black-sample-1"}}
 :some {:other {:name "do-not-mix-this-into-data"}}
 :more-random-values []}
I'm trying to write a pattern that read the name values under from keys in the above data without reading the other names structure regardless of colours used.

Tommi Martin10:05:38

In this case the solution i've created is a dirty one, but in short. I resolve the keys outside of meander functions and then apply the rewrites to the values in a loop. It is definately a dirty code and a solution I wouldn't recommend but with my lack of understanding of meander it was the first working solution to the problem. Proper solution probably uses seqable to find the keys and store the values into a ! type variable if the key matches a pattern. Maybe by using the or statement that captures it's input from the docs or something. But I couldn't get that to work as i ran out of time. if I figure out a proper solution later when work permits on i'll update it here.