Fork me on GitHub
#specter
<
2019-05-06
>
theeternalpulse04:05:57

If I am doing a transform with multi/path how can I refer to the las tthing selected before that path for example

(multi-transform [LAST
                    (multi-path [:a (terminal #_something-here-to-reference-LAST-object)]
                                [:b (terminal dec)])]
                   [1 2 3 4 5 {:a 1 :b 5 :c nil}])

theeternalpulse04:05:29

how can In the terminal statement can I say "give me the LAST from the previous selector before I started branching off"

theeternalpulse04:05:06

do I have ot just have a path that is like [(terminal #(update % :a some-fn (:c %)...)

theeternalpulse04:05:51

(multi-transform [LAST
                    (multi-path [(terminal #(update % :a + (:b %)))]
                                [:b (terminal dec)]
                                [:c (terminal-val 123)])]
                   [1 2 3 4 5 {:a 1 :b 5 :c nil}])
seems to work but wonder if there's a more specter way of doing that

nathanmarz13:05:56

@theeternalpulse use one of the value collection navs, like collect or collect-one

theeternalpulse14:05:08

Ah I see, now that makes the subsequent multipath fns have to take two arguments

theeternalpulse15:05:35

no I tried it, nice solution, need to read through these again,

(multi-transform [LAST
                    (multi-path
                     [(collect-one :b) :a (terminal +)]
                     [:b (terminal dec)]
                     [:c (terminal-val 123)])]
                   [1 2 3 4 5 {:a 1 :b 5 :c nil}])