This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-06
Channels
- # beginners (147)
- # boot (12)
- # chestnut (12)
- # cider (22)
- # clara (10)
- # cljs-dev (6)
- # cljs-experience (3)
- # cljsrn (12)
- # clojure (58)
- # clojure-austin (3)
- # clojure-dusseldorf (25)
- # clojure-finland (20)
- # clojure-gamedev (1)
- # clojure-greece (3)
- # clojure-italy (32)
- # clojure-new-zealand (5)
- # clojure-russia (12)
- # clojure-serbia (1)
- # clojure-spec (4)
- # clojure-uk (51)
- # clojurescript (75)
- # cursive (8)
- # datomic (81)
- # fulcro (29)
- # graphql (16)
- # heroku (6)
- # incanter (1)
- # keechma (1)
- # lumo (44)
- # off-topic (21)
- # onyx (22)
- # parinfer (5)
- # portkey (40)
- # re-frame (43)
- # reagent (5)
- # spacemacs (37)
- # specter (8)
- # unrepl (3)
Hi again! Just trying to grasp navigation and collection a bit better. Let's say I have a recursive structure like so:
{:root {:name "/"
:children {:a {:name "a" :children {<recursive>}}
:b {:name "b" :children {<recursive>}}}}}
I'd like to augment each "node" with the direct path to take to that node:
{:root {:name "/"
:ref [:root]
:children {:a {:name "a" :ref [:root :children :a] :children {<recursive>}}
:b {:name "b" :ref [:root :children :b] :children {<recursive>}}}}}
How would this work with mixing recursive-path
and collect
?@dadair you can do that example like this:
(def data
{:root {:name "/"
:children {:a {:name "a"}
:b {:name "b"}}}})
(def nodes-with-path
(recursive-path [] p
(continue-then-stay
(putval :children)
(must :children)
ALL
(collect-one FIRST)
LAST
p)))
(transform [(putval :root) :root nodes-with-path :ref] (fn [& args] (butlast args)) data)
@nathanmarz that’s very cool
@nathanmarz completely uninformed question: are there similarities between Specter and Gremlin?
@hmaurer I'm not very familiar with Gremlin
thanks @nathanmarz that helps!