Dear all,
thanks for help and pointers.

Introduction of independent range instead of partitioned parts of lazy 
sequence helped achieve parallelism (tested and works 4x faster (4 cores) 
then normal version). 

Here is the code (modified parts in bold):

(def range-end 200000000)
(def is-dividable-by-3-and-5 #(or (zero? (rem % 3))
                       (zero? (rem % 5))))
(time (let [no-processors (.. Runtime getRuntime availableProcessors)
      work (range 0 no-processors)
*      part-size (/ range-end no-processors)
*      result (pmap 
               (fn [part] 
                 (reduce + (filter is-dividable-by-3-and-5 
*                                   (range 
                                     (* part part-size)
                                     (* (inc part) part-size))))) *
               work)]
  (apply + result)) 

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