Fork me on GitHub

@nathanmarz: Thanks for inviting me to specter, I think it's brilliant to have this sort of DSL for navigation, and I'm excited for this lib to transform my workflow! In our conversation yesterday (on #C03S1KBA2) I was talking about needing to post-order traverse a tree. I think I can see how I'd piece that together using specter, but I see talk toward the end of the readme about navigating graphs. What is the best practice if I wanted to post-order traverse a tree?


Hello guys! I made a sort using sorted-map-by then i use into these specter:

(transform (walker (fn [v] (and (keyword? v)))) #(keyword (clojure.string/replace (subs (str %) 1) "/" "_")) sorted-map)
But because inner specter use walker and walker says "Note: "walk" supports all Clojure data structures EXCEPT maps created with sorted-map-by. There is no (obvious) way to retrieve the sorting function." Is there another way to do that with specter?


Or is better make my sort without sorted-map-by?


@josh.freckleton: do you mean best practice if you wanted to post-order traverse a graph?


@nathanmarz: yes, that would be awesome! I don't quite get recursion, or ordering yet in specter


so internally I have a bunch of navigators built on top of loom


so I can do things like (transform [REVERSE-TOPSORT ...] ...)


where reverse-topsort navigates to pairs of [graph, node-id] in reverse topological order


at the end of my clojure/west talk I showed a complete example of my specter/loom integration


trying to encourage someone from the community to build an open-source version


That's odd that clojure.walk/walk claims to not work with sorted-map-by. I just tried it in the REPL and it seems to work fine.


hmm, didn't even know about sorted-map-by


looks like ALL and MAP-VALS are broken with that, but walker does seem to work


@nathanmarz: ah, it wasn't clear you were using loom at the end of that talk. Fantastic talk though! Would you by chance have a gist I could study?


Do priority maps work with ALL?


I make some code for example:

(def demo-map {:a "baa" :b "aab"})

(def demo-map-sorted-by-value (into (sorted-map-by (fn [key1 key2]
                                                       [(get demo-map key1) key1]
                                                       [(get demo-map key2) key2]))) demo-map))

(def result (transform (walker (fn [v] (and (keyword? v)))) #(keyword (clojure.string/replace (subs (str %) 1) "a" "c")) demo-map-sorted-by-value))

demo-map => {:a "baa", :b "aab"}
demo-map-sorted-by-value => {:b "aab", :a "baa"}
result => {:c "baa", :b "aab”}

The question is: Why i lost my sort by value?