Fork me on GitHub

hey everyone. Just started using specter and I’m clearly missing something. Why does this return nil?

(s/select [:groups s/ALL (s/keypath 15)] {:groups {:present {15 "hi"}}})


how would you write this in specter- given a range of numbers, increment the even numbers and remove the odd numbers? i.e. (transform [..] (fn [n] ..) (range 10)) => (1 3 5 7 9) this is a contrived example, but basically I’m transforming the value in one case and removing from the list in another case


@seantempesta: s/ALL creates a sequence of everything refered to by :groups, [[:present {15 "hi"}]] here, so you need to decend another level of the structure. Either with :present or s/LAST would do the trick


@wei You can do it with a navigator like this:

(defpath ALL-ELEM-SEQ []
  (select* [this structure next-fn]
    (mapcat (fn [e] (next-fn [e])) structure)
  (transform* [this structure next-fn]
    (mapcat (fn [e] (next-fn [e])) structure)    


(transform [... ALL-ELEM-SEQ] (fn [[v]] (if (even? v) [(inc v)])))