you are declaring the functions return doubles, but in fact returning functions or doubles
On Tue, Oct 16, 2012 at 11:06 AM, Jim - FooBar(); <jimpil1...@gmail.com> wrote: > Hi everyone, > > I'm pretty sure i'm using trampoline the right way but still I get this > exception: > > ClassCastException Clondie24.lib.search$search$minimize__3075$fn__3076 > cannot be cast to java.lang.Number > Clondie24.lib.search/search/minimize--3075 (search.clj:47) > > here is the code: > > (defn search "The recursive bit of the min-max algorithm." > [eval-fn tree depth] > (letfn [(minimize ^double [tree d] (if (zero? d) (eval-fn (:root tree) > (:direction tree)) > #(r/reduce my-min > (r/map (fn [child] (maximize (:tree child) > (dec d))) (:children tree))))) > (maximize ^double [tree d] (if (zero? d) (eval-fn (:root tree) > (:direction tree)) > #(r/reduce my-max > (r/map (fn [child] (minimize (:tree > child) (dec d))) (:children tree)))))] > (trampoline minimize tree (int depth)))) > > Can anyone shine some light? Is it something that has to do with reducers? > > Jim > > ps: it works fine without trampoline and '#' behind 'r/reduce'. > > > > > -- > 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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