<html><head><style type="text/css">body {word-wrap: break-word; background-color:#ffffff;}</style></head><body><div style="font-family: sans-serif; font-size: 16px">Ooh neat, I will try changing something to a pmap after thinking about which one makes sense. Probably the mapping of error down the population....<br><br><font color="#333333"><i><span style="font-size: 14px"><font face="sans-serif">Connected by DROID on Verizon Wireless</font></span></i></font></div><br><br>-----Original message-----<br><blockquote style="; border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-family: sans-serif; font-size: 14px"><b>From: </b>Lee Spector &lt;lspector@hampshire.edu&gt;<b><br>To: </b>&quot;Wm. Josiah Erikson&quot; &lt;wjerikson@hampshire.edu&gt;<b><br>Cc: </b>cs254f11@lists.hampshire.edu<b><br>Sent: </b>Fri, Nov 18, 2011 22:08:57 GMT+00:00<b><br>Subject: </b>Re: [Cs254f11] subst<br><br></div><br>Doesn't it feel breezy clean? :-)<br><br>And I think you're now ready to go multicore pretty easily, maybe just by judiciously changing a map to a pmap or something along those lines (the details of which will take a little thought about what you want to run concurrently, but in any event it should be quick and safe).<br><br> -Lee<br><br>On Nov 18, 2011, at 4:45 PM, Wm. Josiah Erikson wrote:<br><br>> Yep, now my error function is just (note this is 1/4 the size it was before, I think):<br>> <br>> (reduce + (map #(Math/abs (- (int (eval (postwalk-replace % individual))) %2)) terminal-map scores)))<br>> <br>> That postwalk-replace just pulls out my placeholder function names that were created by calls to random-code, and replaces them with the appropriate numbers for the song, and since it's inside a function that's being mapped down my terminal-map and scores, two lists that correspond to each other, it does it appropriately for each song.<br>> <br>> terminal-map is a list of maps where the keys are function names and the values are what they evaluate to when passed the corresponding song.<br>> <br>> So I now am free of any global re-defing. Yay!<br>>    -Josiah<br>> <br>> <br>> On 11/18/11 2:37 PM, Lee Spector wrote:<br>>> Fabulous!<br>>> <br>>>  -Lee<br>>> <br>>> <br>>> <br>>> On Nov 18, 2011, at 2:30 PM, Wm. Josiah Erikson wrote:<br>>> <br>>>> Yeah, it's perfect (this isn't exactly what I'm going end up doing, but it shows the concept).  This will actually be really easy! Check it out:<br>>>> <br>>>> critic_evolution.core=><br>>>> (use 'clojure.walk)<br>>>> nil<br>>>> <br>>>> critic_evolution.core=><br>>>> (zipmap list-of-retrieval-functions list-of-analysis-functions)<br>>>> {(p_i_m) percent_in_mixolydian,<br>>>> (a_v) average_velocity,<br>>>> (l_c_r_n) least_common_real_note,<br>>>> (p_i_l) percent_in_lydian,<br>>>> (a_n) average_note,<br>>>> (l_n) low_note,<br>>>> (p_o_pb) percentage_of_pitchbend,<br>>>> (p_i_b) percent_in_blues,<br>>>> (m_c_r_n) most_common_real_note,<br>>>> (n_o_d_r_n) number_of_different_real_notes,<br>>>> (h_n) high_note,<br>>>> (a_r_n) average_real_note,<br>>>> (s_d_m) std_dev_mostcom,<br>>>> (p_o_p) percentage_of_percussion,<br>>>> (p_i_p) percent_in_pentatonic}<br>>>> <br>>>> critic_evolution.core=><br>>>> (def function-lookup (zipmap list-of-retrieval-functions list-of-analysis-functions))<br>>>> #'critic_evolution.core/function-lookup<br>>>> critic_evolution.core=><br>>>> (def mark (random-code 5))<br>>>> #'critic_evolution.core/mark<br>>>> critic_evolution.core=><br>>>> mark<br>>>> (max<br>>>> (-<br>>>>  (min (* (p_i_p) (- (l_n) (s_d_m))) (l_c_r_n))<br>>>>  (pmod<br>>>>   (n_o_d_r_n)<br>>>>   (pquot (* (p_i_m) (n_o_d_r_n)) (min (p_i_p) (p_o_pb)))))<br>>>> (pd<br>>>>  (pquot<br>>>>   (pd (- (h_n) (p_i_l)) (- (a_v) (p_i_p)))<br>>>>   (pmod (pmod (l_n) (n_o_d_r_n)) (pmod (p_o_pb) (p_o_pb))))<br>>>>  (pmod (+ (pmod (p_i_b) 78) (pd (n_o_d_r_n) (p_o_pb))) 32)))<br>>>> <br>>>> critic_evolution.core=><br>>>> (postwalk-replace function-lookup mark)<br>>>> (max<br>>>> (-<br>>>>  (min<br>>>>   (* percent_in_pentatonic (- low_note std_dev_mostcom))<br>>>>   least_common_real_note)<br>>>>  (pmod<br>>>>   number_of_different_real_notes<br>>>>   (pquot<br>>>>    (* percent_in_mixolydian number_of_different_real_notes)<br>>>>    (min percent_in_pentatonic percentage_of_pitchbend))))<br>>>> (pd<br>>>>  (pquot<br>>>>   (pd<br>>>>    (- high_note percent_in_lydian)<br>>>>    (- average_velocity percent_in_pentatonic))<br>>>>   (pmod<br>>>>    (pmod low_note number_of_different_real_notes)<br>>>>    (pmod percentage_of_pitchbend percentage_of_pitchbend)))<br>>>>  (pmod<br>>>>   (+<br>>>>    (pmod percent_in_blues 78)<br>>>>    (pd number_of_different_real_notes percentage_of_pitchbend))<br>>>>   32)))<br>>>> <br>>>> critic_evolution.core=><br>>>> <br>>>> On 11/18/11 2:26 PM, Wm. Josiah Erikson wrote:<br>>>>> ..and if I'm reading postwalk-replace's documentation correctly, I can create a map of things to look for and things to replace and it will do all of them. From the documentation:<br>>>>> <br>>>>> Recursively transforms form by replacing keys in smap with their<br>>>>>  values.  Like clojure/replace but works on any data structure.  Does<br>>>>>  replacement at the leaves of the tree first.<br>>>>> <br>>>>> Source:<br>>>>> (defn postwalk-replace<br>>>>>  "...docs..."<br>>>>>  {:added "1.1"}<br>>>>>  [smap form]<br>>>>>  (postwalk (fn [x] (if (contains? smap x) (smap x) x)) form))<br>>>>> <br>>>>> So actually postwalk-replace will do all of my work for me. Yes?<br>>>>> <br>>>>>    -Josiah<br>>>>> <br>>>>> <br>>>>> <br>>>>> On 11/18/11 12:29 PM, Lee Spector wrote:<br>>>>>> Josiah and I discussed this in person, as a way to do what he's doing more simply, and I won't repeat all of our discussion here, but others might find it useful for similar or different purposes.<br>>>>>> <br>>>>>>  -Lee<br>>>>>> <br>>>>>> (use 'clojure.walk)<br>>>>>> <br>>>>>> (defn subst<br>>>>>>   "Returns the given list but with all instances of that (at any depth)<br>>>>>>    replaced with this. Read as 'subst this for that in list'. "<br>>>>>>   [this that lst]<br>>>>>>   (postwalk-replace {that this} lst))<br>>>>>> <br>>>>>> (subst 0 1 '(0 1 2 3 (0 1 2 3 (0 1 2 3) 0 1 2 3) 0 1 2 3))<br>>>>>> <br>>>>>> ; (0 0 2 3 (0 0 2 3 (0 0 2 3) 0 0 2 3) 0 0 2 3)<br>>>>>> <br>>>>>> <br>>>>>> -- <br>>>>>> Lee Spector, Professor of Computer Science<br>>>>>> Cognitive Science, Hampshire College<br>>>>>> 893 West Street, Amherst, MA 01002-3359<br>>>>>> lspector@hampshire.edu, <a href="http://hampshire.edu/lspector">http://hampshire.edu/lspector</a>/<br>>>>>> Phone: 413-559-5352, Fax: 413-559-5438<br>>>>>> <br>>>>>> _______________________________________________<br>>>>>> Cs254f11 mailing list<br>>>>>> Cs254f11@lists.hampshire.edu<br>>>>>> <a href="https://lists.hampshire.edu/mailman/listinfo/cs254f11">https://lists.hampshire.edu/mailman/listinfo/cs254f11</a><br>>>> -- <br>>>> Wm. Josiah Erikson<br>>>> Network Engineer<br>>>> Hampshire College<br>>>> Amherst, MA 01002<br>>>> (413) 559-6091<br>>>> <br>>>> _______________________________________________<br>>>> Cs254f11 mailing list<br>>>> Cs254f11@lists.hampshire.edu<br>>>> <a href="https://lists.hampshire.edu/mailman/listinfo/cs254f11">https://lists.hampshire.edu/mailman/listinfo/cs254f11</a><br>>> --<br>>> Lee Spector, Professor of Computer Science<br>>> Cognitive Science, Hampshire College<br>>> 893 West Street, Amherst, MA 01002-3359<br>>> lspector@hampshire.edu, <a href="http://hampshire.edu/lspector">http://hampshire.edu/lspector</a>/<br>>> Phone: 413-559-5352, Fax: 413-559-5438<br>>> <br>> <br>> -- <br>> Wm. Josiah Erikson<br>> Network Engineer<br>> Hampshire College<br>> Amherst, MA 01002<br>> (413) 559-6091<br>> <br><br>--<br>Lee Spector, Professor of Computer Science<br>Cognitive Science, Hampshire College<br>893 West Street, Amherst, MA 01002-3359<br>lspector@hampshire.edu, <a href="http://hampshire.edu/lspector">http://hampshire.edu/lspector</a>/<br>Phone: 413-559-5352, Fax: 413-559-5438<br><br></blockquote></body></html>