This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-21
Channels
- # admin-announcements (2)
- # aws-lambda (2)
- # beginners (26)
- # boot (179)
- # cider (36)
- # cljs-dev (118)
- # cljsrn (23)
- # clojure (150)
- # clojure-android (1)
- # clojure-austin (7)
- # clojure-austria (3)
- # clojure-canada (1)
- # clojure-dev (7)
- # clojure-dusseldorf (4)
- # clojure-germany (3)
- # clojure-greece (34)
- # clojure-nl (4)
- # clojure-quebec (9)
- # clojure-russia (30)
- # clojure-spec (38)
- # clojure-uk (3)
- # clojurescript (46)
- # clr (1)
- # core-async (2)
- # css (2)
- # cursive (17)
- # datomic (12)
- # devcards (8)
- # dirac (1)
- # docker (2)
- # hoplon (216)
- # jobs (2)
- # kekkonen (1)
- # lein-figwheel (18)
- # leiningen (2)
- # luminus (1)
- # mount (4)
- # off-topic (2)
- # om (15)
- # onyx (1)
- # parinfer (1)
- # pedestal (2)
- # planck (26)
- # reagent (98)
- # spacemacs (6)
- # specter (19)
- # spirituality-ethics (54)
- # untangled (22)
- # vim (24)
- # yada (4)
@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?@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
that bug is fixed for next release https://github.com/nathanmarz/specter/commit/9ff9ef6650d3faab5421dd6452a716421a81554f
@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]
(compare
[(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?@lellis: that should be fixed in master with https://github.com/nathanmarz/specter/commit/9ff9ef6650d3faab5421dd6452a716421a81554f