Re: Possible bug in preduce

2009-02-04 Thread Anand Patil
On Feb 3, 11:09 pm, Rich Hickey wrote: > On Feb 3, 4:43 pm, Anand Patil > wrote: > No, it's not. as the docs for preduce say:http://clojure.org/api#preduce > > "Also note that (f base an-element) might be performed many times" > > in fact, an arbitrary number of times depending on how many pa

Re: Possible bug in preduce

2009-02-04 Thread Zak Wilson
I got a 50% speedup using psort instead of sort with a compute- intensive comparator and a 100 element sequence on a dual-core machine. That said, I found a faster way to do it: I separated the intensive calculations from the comparator - just returning a numeric value. I used pmap to get a seque

Re: Possible bug in preduce

2009-02-03 Thread Mark Engelberg
A month or so ago, I installed the ForkJoin library, and played around with the clojure.parallel wrapper library, and I wasn't able to get a single test to show a speed improvement on my dual core machine. In contrast, pmap, which doesn't rely on the ForkJoin library, works just fine. It makes m

Re: Possible bug in preduce

2009-02-03 Thread Rich Hickey
On Feb 3, 4:43 pm, Anand Patil wrote: > Hi all, > > Messing around with preduce at the REPL I saw this: > > user=> (defn q [sofar new] (do (print new sofar"\n") (+ (+ 1 new) > sofar))) > #'user/q > user=> (reduce q 0 [1 2 > 3]) > 1 0 > 2 2 > 3 5 > 9 > user=> (preduce q 0 [1 2 > 3]) > 3 2 > 6 1

Possible bug in preduce

2009-02-03 Thread Anand Patil
Hi all, Messing around with preduce at the REPL I saw this: user=> (defn q [sofar new] (do (print new sofar"\n") (+ (+ 1 new) sofar))) #'user/q user=> (reduce q 0 [1 2 3]) 1 0 2 2 3 5 9 user=> (preduce q 0 [1 2 3]) 3 2 6 1 8 It looks like preduce takes its arguments in the opposite order from r