Hi,

Is it possible to make Clojure run the following toy program faster
(without changing the algorithm)?

(defn primeQ [n] (primes 2 (/ n 2) n))

(defn divQ [d n] (= (mod n d) 0))

(defn primes [d2 t2 n2]
  (loop [d (int d2) t (int t2) n (int n2)]
    (if (divQ d n) false
        (if (> d t) true
            (recur (inc d) t n)))))

Running this on my machine:

user> (time (primeQ 71378569))
"Elapsed time: 11047.721488 msecs"

is roughly 13 times slower than running the comparable Java program.
It seems like one should be able to do much better for such a
straightforward program. Is there anything I can do to make this
program faster?

Thanks,
Carl

-- 
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

Reply via email to