+1 Lazy is better.
Personally, I would have used filter and map instead of for, but this is probably clearer. Thanks, Alyssa On Dec 6, 10:30 am, Justin Kramer <jkkra...@gmail.com> wrote: > tree-seq makes this pretty simple: > > (defn nested-vals [key coll] > (for [x (tree-seq coll? seq coll) :when (contains? x key)] > (get x key))) > > This works with any type of key and all associative Clojure > structures. It could be made compatible with Java structures by > swapping out the 'coll?' predicate for something more general. > > Justin > > On Dec 5, 9:12 pm, Alex Baranosky <alexander.barano...@gmail.com> > wrote: > > > > > Hi guys, > > > I would like a function to be able to take an arbitrarily nested collection > > and return a sequence of all values of a given key, such as :name, that > > appears anywhere in the nested collection. > > > Does anything like this already exist? > > > Thanks for the help, > > Alex- Hide quoted text - > > - Show quoted text - -- 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