Re: Transforming an ugly nested loop into clojure code

2012-10-02 Thread arekanderu
Thank you for your input Stathis, I will have a look at them as well. On Sunday, September 30, 2012 10:59:05 PM UTC+3, arekanderu wrote: > > Hello, > > I am trying to port an ugly piece of code from Ruby to clojure. So far I > have only ported it to clojure by keeping the same way it was written

Re: Transforming an ugly nested loop into clojure code

2012-10-02 Thread Stathis Sideris
I'm not sure how/if the following would fit your use case exactly, but you might want to explore the get-in function (and assoc-in, the clojure.walk namespace and the zippers functionality. They all make dealing with such deeply nested structures easier. Stathis On Monday, 1 October 2012 23:36

Re: Transforming an ugly nested loop into clojure code

2012-10-01 Thread arekanderu
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 fo

Re: Transforming an ugly nested loop into clojure code

2012-10-01 Thread gaz jones
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? (:item

Re: Transforming an ugly nested loop into clojure code

2012-10-01 Thread arekanderu
I wrote a much better example in order to show what am I trying to do. Of course, the following is a simplified version of the actual code in order to make things easier for everybody. (def my-data [{:area "Somewhere" :warehouses > >[{:warehouse "W54321" :containers > >

Re: Transforming an ugly nested loop into clojure code

2012-09-30 Thread arekanderu
Thank you for your prompt reply Grant. *> May you share the original code? * * * I will post the original function very soon* * *> Why does my-map have vectors storing maps inside instead of a map with > maps inside? * * * Because each vector will have more than one hash-map and each hash map wi

Re: Transforming an ugly nested loop into clojure code

2012-09-30 Thread Grant Rettke
On Sun, Sep 30, 2012 at 2:59 PM, arekanderu wrote: > I am trying to port an ugly piece of code from Ruby to clojure. May you share the original code? > So far I > have only ported it to clojure by keeping the same way it was written in > Ruby and i am trying to re-write it the clojure way becaus

Transforming an ugly nested loop into clojure code

2012-09-30 Thread arekanderu
Hello, I am trying to port an ugly piece of code from Ruby to clojure. So far I have only ported it to clojure by keeping the same way it was written in Ruby and i am trying to re-write it the clojure way because...wellits very ugly. I have a complex hash map which it's structure is always