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" {:foo 1 :bar 2}}}
>    "outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10}}}})
>
> (defn nested-seq [m]
>   (for [[outer-key collections] m
>         [collection-name collection] collections
>         [string-id data] collection]
>     {:outer-key outer-key :collection-name collection-name :string-id 
> string-id :data data}
>     ))
>
> (pprint (nested-seq m))
>
> ;; produces
> ({:outer "outerKeyA",
>   :collection-name :innerKeyA,
>   :string-id "string id",
>   :data {:foo 1, :bar 2}}
>  {:outer "outerKeyB",
>   :collection-name :innerKeyB,
>   :string-id "string id",
>   :data {:bar 5, :baz 10}})
>
>
>
> for list comprehensions behave like doseq except that they return whatever 
> the body does, thus letting you move your side effects somewhere else.
>
> Maybe this helps,
> /thomas
>
> On Tuesday, December 10, 2013 12:48:56 PM UTC+1, Thomas Heller wrote:
>>
>> 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 all,
>>>
>>> I am trying to figure out a better way to loop the following map than 
>>> using nested doseq. The map has the following structure:
>>>
>>> (def m
>>>>   {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}}
>>>>    "outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10}}}})
>>>
>>>
>>> So, right now i am doing the following:
>>>
>>> (doseq [[outer-keys collections] m]
>>>>   (doseq [[collection-name collection] collections]
>>>>     (doseq [[string-id data] collection]
>>>>       ;; do stuff with all the above 
>>>> )))
>>>
>>>
>>> Is there a more idiomatic/better way to do deeply nested 
>>> iterations/traversal of map of maps?
>>>
>>> Thank you for any replies!
>>>
>>> Ryan 
>>>
>>>

-- 
-- 
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/groups/opt_out.

Reply via email to