Thank you Gaz for your reply. You are correct about the side effects. I will go through your example more carefully and give it a go. It definitely looks more promising than what I got :)
On Tuesday, October 2, 2012 1:22:44 AM UTC+3, Gaz wrote: > > 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 <areka...@gmail.com<javascript:>> > 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 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