Each node is represented as map:
{prop1 prop2 prop3 children}
children is a vector of nested nodes
[
prop1
prop2
children
[
{prop1 prop2 children []}
{prop1 prop2 children [{new-node} {new-node} ... {another-node}]
]
[
{prop1 prop2 children []}
{prop1 prop2 children [{new-node} {new-node}]
]
]
I need to traverse the structure to find the node (the map data structure)
that has a specific value, say for prop2.
I tried:
(defn is-it-node? [coll]
(not (nil? (get coll "children"))))
(filter #(= "12345" (get % "prop2")) (tree-seq #(is-it-node? %) identity
navigation-tree))
But I'm getting nothing actually.
On Wednesday, August 19, 2015 at 5:36:42 PM UTC+2, Gary Verhaegen wrote:
>
> If you want more specific answers, you'll need to describe the
> structure of your tree. In particular, what is the relationship
> between your conceptual nodes and your data structures (vectors and
> maps)?
>
> On 19 August 2015 at 17:26, Andy- <[email protected] <javascript:>>
> wrote:
> > I have yet to evaluate it myself but this might do help you:
> >
> > https://github.com/nathanmarz/specter
> >
> >
> > On Wednesday, August 19, 2015 at 10:18:06 AM UTC-4, Hussein B. wrote:
> >>
> >> Hi,
> >>
> >> I have transformed JSON response into the equivalent data structure
> using
> >> Cheshire library.
> >>
> >> The result is a huge nested data structure , mostly vectors and maps.
> It
> >> is actually a tree.
> >>
> >> How to find a property that is nested deep inside the tree ? For
> example
> >> I'm search for the node that has the value zyx for property "uuid".
> >>
> >> What I'm supposed to use? Something like zipper or walk? or something
> >> simpler is available?
> >>
> >> Thanks for help.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to [email protected]
> <javascript:>
> > Note that posts from new members are moderated - please be patient with
> your
> > first post.
> > To unsubscribe from this group, send email to
> > [email protected] <javascript:>
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> Groups
> > "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.