Fork me on GitHub
#meander
<
2020-04-06
>
grounded_sage14:04:17

How would I rewrite a single vector in an arbitrarily nested vector? I want to add some properties to a Malli schema.

noprompt16:04:44

You can do it with $

noprompt16:04:47

(me/rewrite '[:A
              [:B [:C 1 2] [:C 3 [:D 4 5]]]
              [:B [:C 6 7] [:C 8 [:D 9 10]]]]
  (me/$ ?loc [:D 4 5 :as ?D])
  (me/$ ?loc [:D YOU WIN]))
;; =>
[:A
 [:B [:C 1 2] [:C 3 [:D YOU WIN]]]
 [:B [:C 6 7] [:C 8 [:D 9 10]]]]

noprompt16:04:20

Or like @U5K8NTHEZ said, you can use strategies.

grounded_sage18:04:03

I found out that there is an updating function built in so I went with that in the end.

👍 4
Jimmy Miller16:04:05

Strategies are the best thing we have for this right now.