From: gaz jones <gareth.e.jo...@gmail.com>
Date: Mon, 1 Oct 2012 17:22:18 -0500
Local: Mon, Oct 1 2012 6:22 pm
Subject: Re: Transforming an ugly nested loop into clojure code
You appear to be running over the map purely for side-effects,
therefore off the top of my head something like: (defn my-func
Might be more appropriate...
On Mon, Oct 1, 2012 at 5:07 PM, arekanderu <arekand...@gmail.com> 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
>> (:items box))
>> (doSomethingElse (:warehouse warehouse)
>> (:boxes container)))
>> (:containers warehouse)))
>> (:warehouses area)))
>> data))
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||