You appear to be running over the map purely for side-effects,
therefore off the top of my head something like:
(defn my-func
[data]
(doseq [area data
warehouse (:warehouses area)
container (:containers warehouse)
box (:boxes container)]
(if-not (empty? (:items box))
(doseq [item (:items box)] (do-something (:box box) (:item item)))
(do-something-else (:warehouse warehouse)
(:container container)
(:box box)))))
Might be more appropriate...
On Mon, Oct 1, 2012 at 5:07 PM, arekanderu <[email protected]> wrote:
>> (def my-data [{:area "Somewhere" :warehouses
>>
>> [{:warehouse "W54321" :containers
>>
>> [{:container "C12345" :boxes
>>
>> [{:box "B12345" :items
>>
>> [{:item "I12345"}]}]}]}]}
>>
>> {:area "SomewhereElse" :warehouses
>>
>> [{:warehouse "W54321" :containers
>>
>> [{:container "C54321" :boxes
>>
>> [{:box "B54321" :items
>>
>> [{:item "I54321"}]}]}]}]}])
>>
>>
>> (defn my-func [data]
>>
>> (map (fn [area]
>>
>> (map (fn [warehouse]
>>
>> (map (fn [container]
>>
>> (map (fn [box]
>>
>> (if (not (empty? (:items box)))
>>
>> (map (fn [item]
>>
>> (doSomething (:box box) (:item
>> item)))
>>
>> (:items box))
>>
>> (doSomethingElse (:warehouse warehouse)
>> (:container container) (:box box))))
>>
>> (:boxes container)))
>>
>> (:containers warehouse)))
>>
>> (:warehouses area)))
>>
>> data))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en