Sorry, the first example fn is confusing--I'd probably use assoc rather
than update-in:

>   (reduce #(assoc %1 %2 (do-aspected-stuff ...)) {} personals))


(2014/06/20 22:28), Dave Della Costa wrote:
> Rather than start with the code you are trying to duplicate, consider
> the data structure(s) that you have as input and the data structure you
> want to end up with.
> 
> It's certainly possible to emulate the kind of nested loop structure you
> are asking about in Clojure, but most likely it's not how you'd
> structure the solution in the first place.  For one, the Ruby example
> heavily depends on mutability, which is not as common in Clojure-land.
> 
> But here's one "rough sketch," just as a simple example:
> 
> I might make personals and aspected vectors of keywords, and I'd end up
> doing something more like
> 
> (def find-aspects
>   [astro-data]
>   (reduce #(update-in %1 [%2] (do-aspected-stuff ...)) {} personals))
> 
> With do-aspected-stuff being something like:
> 
> (defn do-aspected-stuff
>   [personal-key astro-data]
>   (reduce #(if (= personal-key %2) %1 (calc-angles astro-data %1 %2)) {}
> aspected))
> 
> and so on and so forth with calc-angles doing its own looping thing with
> all the calculations you have to do (glossing over the rest as hopefully
> you get the picture at this point), and everything gets deposited in the
> hash-map at the very top of the chain at the end.
> 
> Hope this helps.
> 
> DD
> 
> (2014/06/20 22:11), gvim wrote:
>> On 20/06/2014 13:38, Timothy Baldridge wrote:
>>> Care to explain? How does it get much simpler than:
>>>
>>> (for [x some-collection
>>>         y x
>>>        z y]
>>>    z)
>>>
>>
>> Because it's 3 levels deep and requires substituting the vars back into
>> maps to then create a returned map. Your for example doesn't emulate
>> Ruby's each_with_index, as in the example, as far as I'm aware. I'm
>> fairly new to Clojure so the obvious may not be so obvious to me yet :)
>>
>> gvim
>>

-- 
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/d/optout.

Reply via email to