" I get a typical clojure-y set of data fairly deeply nested data 
structures that I have yet to master with respect to traversing  using 
basic clojure operations"

You get an arbitrarily nested Clojure, not Clojure-y, data structure 
precisely because those maps, lists, and sets suffice in 99% of cases and 
the language has probably the best set of functions (including those data 
structures themselves!) for working with them of any language out there. 
Honestly, Clojure's data structures and the suite of polymorphic functions 
that go with them are kind of the whole point of the language. Just keep 
practicing using them. 

2 maps, a flatten, a select-keys, and....data...

(->> (describe-instances)
       :reservations
       (map :instances)
       flatten
       (map #(select-keys % [:instance-id :instance-type 
:public-ip-address]))) ;; whatever other keys you're interested in



On Wednesday, March 12, 2014 4:13:06 AM UTC-7, Dave Tenny wrote:
>
> If I do something like a describe-instances call in amazonica, I get a 
> typical clojure-y set of data fairly deeply nested data structures
> that I have yet to master with respect to traversing  using basic clojure 
> operations.
>
> Given a result that basically ends up looking like pages of interleaved 
> maps and arrays, what should I be using to pick out
> nested key/value information?
>
> {:reservations [{:reservation-id "r-3da23a55",
> ... pages of output ...
> }]}]}]}
> user=>
>
> 'get-in' won't do it because of the arrays (or PersistentArrayMaps, as the 
> case may be).
> I was hoping to avoid zippers, but maybe that is the idiomatic way to do 
> it, I don't know.
>
>  What's the easy way to traverse these things?  This is a very common data 
> pattern in using clojure to access everything from html content to AWS data.
>  I just want to pluck out the :instance k/v information in the nested 
> morass of data printed at my REPL but I haven't yet found the intuitive and 
> idiomatic way to do it.
>
>
>
>
>
>

-- 
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 that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to