Fork me on GitHub
#specter
<
2017-05-01
>
nijssels18:05:28

Why do the following statements work...

nijssels18:05:49

But the combination doesnt...

nijssels18:05:19

This works... It must be the workings of select-one...

levitanong18:05:33

@nathanmarz I can’t seem to find documentation on traverse-all. Tried using it as if it were a transducer version of traverse but it doesn’t seem to work exactly like that.

nathanmarz18:05:07

@nijssels MAP-VALS navigates you to each value individually, which means you're calling FIRST on a number

nathanmarz18:05:36

you can do (select-first MAP-VALS {:a 1 :b 2 :c 3})

levitanong18:05:19

ok that makes sense. thanks!

nijssels18:05:31

Of course. Thanks @nathanmarz!

urbank21:05:09

I probably should have figured this out, but how do recursively navigate this kind of data-structure

urbank21:05:15

I want to get to all the maps that have a :children key

nathanmarz22:05:23

@urbank

(def data
  {:data 10
   :children [{:data [1 2 3]
               :children []}
              {:data [4 5 6]
               :children []}]})


(def NODES
  (recursive-path [] p
    (continue-then-stay :children ALL p)
    ))

(select [NODES :data] data)
;; => [[1 2 3] [4 5 6] 10]

urbank22:05:02

@nathanmarz Oh cool, thanks! For some reason I thought there needed to be a terminating clause in a recursive path, but I suppose it just stops when it runs out of results

urbank22:05:43

Still don't quite understand what Navigates to the provided path and then to the current element means. Stay as opposed to what?

nathanmarz22:05:23

@urbank as opposed to only navigating to the provided subpath

nathanmarz22:05:14

(select (continue-then-stay :a) {:a 1}) ; => [1 {:a 1}]

nathanmarz22:05:34

it navigates to :a, then navigates to itself