On Sat, Nov 6, 2010 at 5:50 PM, Juha Arpiainen <jarpi...@gmail.com> wrote: > On Nov 6, 7:57 pm, Ken Wesson <kwess...@gmail.com> wrote: >> (filter identity (map #(if %1 %2) (drop 2 sieve) (iterate inc 2))) > > Returning a lazy seq doesn't seem to make much sense here, > especially since (map ... (drop 2 sieve)) holds onto the > sieve array. Returning a vector instead drops the runtime > of (time (count (primes-to 10000000))) from 5.3 s to 0.5 s > on my machine
That doesn't make much sense. At some point the sieve has to be groveled over and the appropriate indices emitted. Whether that occurs lazily or promptly shouldn't make a difference to speed, let alone one of that magnitude. Skipping over the even entries after 2 could speed things up somewhat but not nearly that much ... Either there's something massively inefficient about map (or iterate) or there's something else hinky going on here. -- 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