Re: How can find something inside heavily nested data structure ?

2015-09-18 Thread Sean Duckett
If you're using emacs with cider, you might try `cider-repl-clear-buffer`. This has saved my emacs session in situations where I accidentally print a large XML structure. --smd. On 08/20, Dave Tenny wrote: > I'm still in search of tools that let me get a good sense of *what* to > navigate when

Re: How can find something inside heavily nested data structure ?

2015-08-25 Thread Brian Marick
Dave Tenny wrote: Specter looks nice. I didn't see any examples in the readme or tests for working with more deeply nested data structures such as those discussed in this thread, any pointers? Here's an example that might be relevant to the original question. Suppose you have this

Re: How can find something inside heavily nested data structure ?

2015-08-24 Thread Dave Tenny
Specter looks nice. I didn't see any examples in the readme or tests for working with more deeply nested data structures such as those discussed in this thread, any pointers? On Sunday, August 23, 2015 at 10:22:25 PM UTC-4, Brian Marick wrote: Andy- wrote: I have yet to evaluate it

Re: How can find something inside heavily nested data structure ?

2015-08-23 Thread henrik42
OK, so in this special case you one would just use (def s [{n {id a} d 2 children [{n {id c} d 4 children nil}]} {n {id b} d 3 children nil}]) (some (fn [x] (and (map? x) (some #{{id c}} (vals x (tree-seq coll? seq s)) -- You received this message because

Re: How can find something inside heavily nested data structure ?

2015-08-23 Thread Brian Marick
Andy- wrote: I have yet to evaluate it myself but this might do help you: https://github.com/nathanmarz/specter Specter is great. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note

Re: How can find something inside heavily nested data structure ?

2015-08-22 Thread henrik42
I like using tree-seq and core.match when working on instaparse ASTs - like this: (require ['clojure.core.match :as 'm]) (def s [{n {id a} d 2 children [{n {id c} d 4 children nil}]} {n {id b} d 3 children nil}]) ;; top-down-traversal (defn nodes [x] (tree-seq coll? seq x)) ;; target

Re: How can find something inside heavily nested data structure ?

2015-08-21 Thread Hussein B.
Yes, that does the job. Thanks for your help and time. On Thursday, August 20, 2015 at 12:21:47 AM UTC+2, Alan Forrester wrote: On 19 Aug 2015, at 18:08, Hussein B. hubag...@gmail.com javascript: wrote: Here is more concrete example (def s [{n {id a} d 2 children [{n {id c} d 4

Re: How can find something inside heavily nested data structure ?

2015-08-20 Thread Dave Tenny
I have found the core 'get-in' function to be useful for extracting data from big trees of clojure data structures, perhaps that will help. I'm still in search of tools that let me get a good sense of *what* to navigate when looking at such trees of data structures from API's and/or data

How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
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

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Gary Verhaegen
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- andre.r...@gmail.com wrote: I have yet to evaluate it myself

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Marc O'Morain
Hi Hussein, A combination of filter and tree-seq might do what you need. Marc On 19 August 2015 at 15:18, Hussein B. hubaghd...@gmail.com wrote: Hi, I have transformed JSON response into the equivalent data structure using Cheshire library. The result is a huge nested data structure ,

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
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}

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Andy-
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

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
Here is more concrete example (def s [{n {id a} d 2 children [{n {id c} d 4 children nil}]} {n {id b} d 3 children nil}]) I want to find the map that has value c for id. If found, I need to return the map {n {id c} d 4 children nil} On Wednesday, August 19, 2015 at 5:36:42 PM UTC+2, Gary

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread 'Alan Forrester' via Clojure
On 19 Aug 2015, at 18:08, Hussein B. hubaghd...@gmail.com wrote: Here is more concrete example (def s [{n {id a} d 2 children [{n {id c} d 4 children nil}]} {n {id b} d 3 children nil}]) I want to find the map that has value c for id. If found, I need to return the map {n {id c} d 4