Re: Best way to loop a map of maps

2014-01-21 Thread Ryan
Thank you for your input Thomas. All replies have definitely been very useful :) Cheers, Ryan On Tuesday, December 10, 2013 1:57:38 PM UTC+2, Thomas Heller wrote: > > Oh nvm, just saw that it was suggested before. > > But maybe this is new: > > (def m > {"outerKeyA" {:innerKeyA {"string id" {

Re: Best way to loop a map of maps

2013-12-10 Thread Thomas Heller
Oh nvm, just saw that it was suggested before. But maybe this is new: (def m {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}} "outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10) (defn nested-seq [m] (for [[outer-key collections] m [collection-name collection] collecti

Re: Best way to loop a map of maps

2013-12-10 Thread Thomas Heller
FWIW you can simplify the nested doseqs like this (doseq [[outer-keys collections] m [collection-name collection] collections [string-id data] collection] ;; do stuff with the above ) HTH, /thomas On Wednesday, December 4, 2013 12:05:14 AM UTC+1, Ryan wrote: > > Hi a

Re: Best way to loop a map of maps

2013-12-10 Thread Ryan
I've seen postwalk and prewalk but never really played around with them so I will give it a shot. Thanks for your input! Ryan On Tuesday, December 10, 2013 10:29:51 AM UTC+2, Jeroen van Dijk wrote: > > Don't forget about the option of walking over a map by using > clojure.walk/postwalk or cloj

Re: Best way to loop a map of maps

2013-12-10 Thread Jeroen van Dijk
Don't forget about the option of walking over a map by using clojure.walk/postwalk or clojure.walk/prewalk I use these functions often lately. Especially useful if you have to update values in your map and they could occur anywhere. It is a bit tricky to get working at first, because the return va

Re: Best way to loop a map of maps

2013-12-05 Thread Ryan
Thanks guys for the useful answers :) Ryan On Wednesday, December 4, 2013 1:27:57 AM UTC+2, James Ferguson wrote: > > `update-in` could be helpful, depending on what exactly you're doing. > > (doseq [keyA keys, keyB otherkeys] > (update-in m [keyA keyB] some-function)) > > On Tuesday, December

Re: Best way to loop a map of maps

2013-12-03 Thread James Ferguson
`update-in` could be helpful, depending on what exactly you're doing. (doseq [keyA keys, keyB otherkeys] (update-in m [keyA keyB] some-function)) On Tuesday, December 3, 2013 6:05:14 PM UTC-5, Ryan wrote: > > Hi all, > > I am trying to figure out a better way to loop the following map than > u

Re: Best way to loop a map of maps

2013-12-03 Thread Cedric Greevey
Tree-seq? But then, if the data is structured so each level has a distinct purpose, that's not really a great fit. Perhaps we need a for/doseq analog of assoc-in, update-in, etc.? At the very least I think this might work: (doseq [[outer-keys collections] m [collection-name collection] c

Re: Best way to loop a map of maps

2013-12-03 Thread Jay Fields
I was going to type in the example with multiple bindings, but this will probably be more helpful: http://blog.jayfields.com/2013/05/clojure-combining-calls-to-doseq-and-let.html On Tue, Dec 3, 2013 at 6:05 PM, Ryan wrote: > Hi all, > > I am trying to figure out a better way to loop the following