Re: trampoline not compatible with reducers?

2012-10-16 Thread Jim - FooBar();
On 16/10/12 21:45, Alan Malloy wrote: 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 stack

Re: trampoline not compatible with reducers?

2012-10-16 Thread Alan Malloy
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

Re: trampoline not compatible with reducers?

2012-10-16 Thread Jim - FooBar();
'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

Re: trampoline not compatible with reducers?

2012-10-16 Thread Kevin Downey
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(); wrote: > On 16/10/12

Re: trampoline not compatible with reducers?

2012-10-16 Thread Jim - FooBar();
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

Re: trampoline not compatible with reducers?

2012-10-16 Thread Kevin Downey
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(); wrote: > Hi everyone, > > I'm pretty sure i'm using trampoline the right way but still I get this > exception: > > ClassCastException Clondie24.lib.search$s

trampoline not compatible with reducers?

2012-10-16 Thread Jim - FooBar();
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 sea