On 20/06/2014 14: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
Great, thanks. These are the kind of pointers I was looking for without
expecting anyone to do the whole job :). Someone on IRC also mentioned
prismatic/plumbing as possibly helpful.
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.