Re: Speed issues vs. Python

2009-03-13 Thread Christophe Grand
It wont solve your performance problem but I think that your python code translates to: (defn f[a b c] (+ (* c c c c) (* b b b) (* a a))) (count (into #{} (for [c primes :while (< (f (first primes) (first primes) c) limit) b primes :while (< (f (first primes) b c) limit)

Re: Speed issues vs. Python

2009-03-13 Thread André Thieme
On 12 Mrz., 07:48, tristan wrote: > my clojure version > http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1... Not about speed, but about readability: (loop [c primes n #{}] (let [r (loop [b primes n n] (let [r (loop [a primes n n] ...))) You should think about us

Re: Speed issues vs. Python

2009-03-12 Thread Sergio
You should profile your code. A cousin of mine was solving a problem from programmingchallenges.com in C++. I wrote a solution in Clojure. At the beginning, my version was astronomically slower. After profiling, I reduced it to about 2x slower. After modifying it to use Java arrays, it actually b

Re: Speed issues vs. Python

2009-03-12 Thread bOR_
Setting that one (set! *warn-on-reflection* true) Helped a lot in my simulation model to find out where clojure/java were having trouble. It pointed out that one of my main functions was causing trouble, and could do with a bit of typehinting. (defn #^Short find-all-epi "turns the rx and stri