Reducers don't enter into the picture at all: this code is just as broken with clojure.core/reduce and clojure.core/map. The immediate problem that Kevin is trying to draw your attention to is that you are calling (reduce max (map my-fn coll)), where my-fn sometimes returns a number, and sometimes a thunk. Obviously max can't be expected to compare thunks for you, so that's no good. His suggestion is to make sure to trampoline the results of (map my-fn coll) until you get out a list of numbers, and then find the max.
But really I don't think trampoline is a very compelling problem- solver here: the primary (only?) gain from trampoline is in reducing stack depth, and I rather doubt that you can calculate minimax for even a few hundred ply. So you're in no danger of a stackoverflow, but are sacrificing readability and a smidge of performance to keep your stack "really small" instead of "not big enough to be a problem". On Oct 16, 12:45 pm, "Jim - FooBar();" <jimpil1...@gmail.com> wrote: > 'my-min' and 'my-max' simply wrap core/min core/max. You mean i have to > trampoline these calls as well? return something like this? : > > #(r/reduce (trampoline my-max) ;;was my-max > (r/map (fn [child] (minimize (:tree > child) (dec d))) (:children tree))) > > Jim > > On 16/10/12 20:01, Kevin Downey wrote: > > > > > > > > > if you look further down the stacktrace (where it refers to your code > > instead of clojure.lang.Numbers.lt) it will give you line numbers in > > your code to look at. > > > you are calling these trampolined functions without trampoline. > > > On Tue, Oct 16, 2012 at 11:24 AM, Jim - FooBar(); <jimpil1...@gmail.com> > > wrote: > >> On 16/10/12 19:15, Kevin Downey wrote: > >>> you are declaring the functions return doubles, but in fact returning > >>> functions or doubles > >> yes you're right (my bad) but the same thing happens without the > >> type-hinting - albeit in a different place and different originating > >> function: > > >> ClassCastException Clondie24.lib.search$search$maximize__3081$fn__3082 > >> cannot be cast to java.lang.Number clojure.lang.Numbers.lt > >> (Numbers.java:219) > > >> Jim > > >> -- > >> 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 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