I have a method in Ruby that involves 3-level enumeration and would like to rewrite it in Clojure. Without asking anyone to do the job :), what is the best equivalent to this kind of Ruby iteration in Clojure? I looked at prewalk and postwalk but wasn't convinced that was what's required. Map could also get a bit messy here.

gvim


****************************************************************
SIGNS = { ar:'Aries', ta:'Taurus', ge:'Gemini', cn:'Cancer', le:'Leo', vi:'Virgo', li:'Libra', sc:'Scorpio', sa:'Sagittarius', cp:'Capricorn', aq:'Aquarius', pi:'Pisces' } RULERS = {Aries:[:Mars], Taurus:[:Venus], Gemini:[:Mercury], Cancer:[:Moon], Leo:[:Sun], Virgo:[:Mercury], Libra:[:Venus], Scorpio:[:Mars, :Pluto], Sagittarius:[:Jupiter], Capricorn:[:Saturn], Aquarius:[:Saturn, :Uranus], Pisces:[:Jupiter, :Neptune]} ANGLES = {cnj:{orb:7.5, deg:[0], type:'g'}, squ:{orb:6, deg:[90,270], type:'r'}, tri:{orb:6, deg:[120,240], type:'g'}, opp:{orb:7.5, deg:[180], type:'r'}}
PERSONALS = %i(Sun Moon Mercury Venus Mars)
ASPECTED = %i(Sun Moon Mercury Venus Mars Jupiter Saturn Uranus Neptune Pluto)


def find_aspects(astro_data)
  results = {}
  PERSONALS.each_with_index do |p,i|
    results[p] = {}
    ASPECTED[i+1..9].each do |a|
      next if p == a
      ANGLES.each do |asp, data|
        data[:deg].each do |d|
          exact = astro_data[p][:long] + d
          exact -= 360 if exact >= 360
          range_start = exact - data[:orb]
range_end = (exact + data[:orb] >= 360) ? (exact + data[:orb] - 360) : (exact + data[:orb])
          target_long = astro_data[a][:long]
          if target_long >= range_start && target_long <= range_end
width = target_long <= exact ? (exact - target_long) : (target_long - exact)
            results[p][a] = [asp,width]
          end
        end
      end
    end
  end
  return results
end

--
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