beginners

2025-05-28T07:52:08.114499Z

Hi I have a deeply nested datastructure (maps and vectors) where i need to find the paths to a value. What's the best way to achieve this?

(def data {:a [{:b 1 :c 2}, {:b 3 :c 4 :d 1}]}

(??? data 1) => [[:a 0 :b] [:a 1 :d]]

a13 2025-05-28T07:56:05.895299Z

reduce-kv or smth like that

2025-05-28T07:59:38.321689Z

Thanks will have a look 👍

a13 2025-05-28T08:02:43.775849Z

the nice thing about it, is it works for vectors too, the "key" being the index of an element

escherize 2025-05-28T22:19:03.327299Z

This does something similar, fwiw: https://github.com/escherize/tracks/blob/master/src/tracks/core.cljc#L4

2025-05-30T09:08:15.407259Z

Thanks for the example