Hi, Am Donnerstag, 20. Juni 2013 15:19:40 UTC+2 schrieb John Holland: > > (defn triangle [n] (reduce + (range n))) > (def lazytri (lazy-seq (map triangle (range)))) > > Some quick idea: here is a major difference in your clojure and your java implementation. You always recompute the whole sum for each step. While you only increase a counter in the java version. A better lazytri implementation would be:
(def lazytri (reductions + (range 1 Long/MAX_VALUE))) You don't use sqrt in your clojure version? inc is faster than (+ 1 ...). zero? is faster than (= 0 ...). Kind regards Meikel -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.