<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-2726786215957001832.post2964382756060248812..comments</id><updated>2009-06-30T07:29:15.227Z</updated><category term='Swing'/><category term='yaml'/><category term='dart'/><category term='Tomcat'/><category term='Scala'/><category term='Ivy'/><category term='soy'/><category term='guice'/><category term='appengine'/><category term='java'/><category term='JMX'/><category term='groovy'/><category term='html'/><category term='gdata'/><category term='Processing'/><category term='YQL'/><category term='maven'/><category term='ScalaVsGroovy'/><category term='Spring'/><category term='exif'/><category term='Ant'/><category term='google'/><category term='gnome'/><title type='text'>Comments on Froth &amp;amp; Java: Sieve of Eratosthenes</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.frothandjava.com/feeds/2964382756060248812/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html'/><author><name>Scot McSweeney-Roberts</name><uri>http://www.blogger.com/profile/05078277004789544258</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2726786215957001832.post-2551094809231634107</id><published>2009-06-30T07:29:15.227Z</published><updated>2009-06-30T07:29:15.227Z</updated><title type='text'>What do you think about this stream based implemen...</title><content type='html'>What do you think about this stream based implementation?&lt;br /&gt;&lt;br /&gt;def primes: Stream[Int] = {&lt;br /&gt;        import scala.collection.SortedSet&lt;br /&gt;        import scala.collection.immutable.TreeSet&lt;br /&gt;        def ps(tuple:(Int,SortedSet[Int])):Stream[(Int, SortedSet[Int])] = {&lt;br /&gt;            def np(n:Int):(Int, SortedSet[Int]) =&lt;br /&gt;               if (tuple._2.takeWhile(p =&amp;gt; p*p &amp;lt;= n).exists(n % _ == 0)) np(n+2) &lt;br /&gt;               else (n, TreeSet(n) ++ tuple._2)&lt;br /&gt;            Stream.cons(tuple, ps(np(tuple._1 + 2)))&lt;br /&gt;        }&lt;br /&gt;        Stream.cons((2, TreeSet(2)),ps((3, TreeSet(2,3)))).map(_._1)&lt;br /&gt; }</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/2551094809231634107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/2551094809231634107'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html?showComment=1246346955227#c2551094809231634107' title=''/><author><name>Landei</name><uri>http://www.blogger.com/profile/04894331070342867122</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html' ref='tag:blogger.com,1999:blog-2726786215957001832.post-2964382756060248812' source='http://www.blogger.com/feeds/2726786215957001832/posts/default/2964382756060248812' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-128307745'/></entry><entry><id>tag:blogger.com,1999:blog-2726786215957001832.post-7733999500955709507</id><published>2009-06-29T18:49:42.834Z</published><updated>2009-06-29T18:49:42.834Z</updated><title type='text'>Instead of first/drop, use head/tail. You are usin...</title><content type='html'>Instead of first/drop, use head/tail. You are using a list, after all, and first, for one, is scheduled for deprecation.&lt;br /&gt;&lt;br /&gt;You can test xs.head*xs.head &amp;lt; xs.last as the if condition instead of xs.isEmpty, and that will give you proper Sieve implementation without any trouble. That will cause the list to be traversed at each recursion, which isn&amp;#39;t nice. Instead, since nomults is internal, you should add a third parameter, and pass &amp;quot;n&amp;quot; in it at sieve&amp;#39;s call to nomult.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/7733999500955709507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/7733999500955709507'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html?showComment=1246301382834#c7733999500955709507' title=''/><author><name>Daniel</name><uri>http://www.blogger.com/profile/07505997833685327219</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_vHc2CW-BnIc/SczHGsWJNGI/AAAAAAAAAJE/Qc61w-ONjZo/S220/03022009213.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html' ref='tag:blogger.com,1999:blog-2726786215957001832.post-2964382756060248812' source='http://www.blogger.com/feeds/2726786215957001832/posts/default/2964382756060248812' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-646094553'/></entry><entry><id>tag:blogger.com,1999:blog-2726786215957001832.post-6000328114186795567</id><published>2009-06-29T18:18:04.509Z</published><updated>2009-06-29T18:18:04.509Z</updated><title type='text'>I agree with Daniel. Besides not implementing the ...</title><content type='html'>I agree with Daniel. Besides not implementing the s.o.e. it also performs worse. Oh and runs out of heap space quickly. Have a look at the LtU link. Quite enlightening.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/6000328114186795567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/6000328114186795567'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html?showComment=1246299484509#c6000328114186795567' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html' ref='tag:blogger.com,1999:blog-2726786215957001832.post-2964382756060248812' source='http://www.blogger.com/feeds/2726786215957001832/posts/default/2964382756060248812' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1697405302'/></entry><entry><id>tag:blogger.com,1999:blog-2726786215957001832.post-7874418330884500623</id><published>2009-06-29T18:05:42.712Z</published><updated>2009-06-29T18:05:42.712Z</updated><title type='text'>That example on scaladoc is not actually a Sieve o...</title><content type='html'>That example on scaladoc is not actually a Sieve os Eratosthenes. See http://lambda-the-ultimate.org/node/3127.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/7874418330884500623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/7874418330884500623'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html?showComment=1246298742712#c7874418330884500623' title=''/><author><name>Daniel</name><uri>http://www.blogger.com/profile/07505997833685327219</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_vHc2CW-BnIc/SczHGsWJNGI/AAAAAAAAAJE/Qc61w-ONjZo/S220/03022009213.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html' ref='tag:blogger.com,1999:blog-2726786215957001832.post-2964382756060248812' source='http://www.blogger.com/feeds/2726786215957001832/posts/default/2964382756060248812' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-646094553'/></entry><entry><id>tag:blogger.com,1999:blog-2726786215957001832.post-3918067421538284547</id><published>2009-06-29T16:05:28.459Z</published><updated>2009-06-29T16:05:28.459Z</updated><title type='text'>The scaladoc page for Stream has an implementation...</title><content type='html'>The scaladoc page for Stream has an implementation using streams, for comparison.&lt;br /&gt;http://www.scala-lang.org/docu/files/api/scala/Stream.html</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/3918067421538284547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2726786215957001832/2964382756060248812/comments/default/3918067421538284547'/><link rel='alternate' type='text/html' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html?showComment=1246291528459#c3918067421538284547' title=''/><author><name>Dean Wampler</name><uri>http://www.blogger.com/profile/02505288380679936730</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://2.bp.blogspot.com/_uHbp-tKvc_o/SYA5jKd7heI/AAAAAAAAAAk/ZpdvaaRhkVk/S220/DEAN_W_medium.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.frothandjava.com/2009/06/sieve-of-eratosthenes.html' ref='tag:blogger.com,1999:blog-2726786215957001832.post-2964382756060248812' source='http://www.blogger.com/feeds/2726786215957001832/posts/default/2964382756060248812' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-512748780'/></entry></feed>
