<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: An Enumeration of Prime Numbers with Anonymous Methods</title>
	<atom:link href="http://blogs.teamb.com/craigstuntz/2008/08/28/37831/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/</link>
	<description>C# • Delphi • Entity Framework • Functional Programming • InterBase • MVC • .NET • Web</description>
	<pubDate>Tue, 16 Mar 2010 07:31:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Paweł Głowacki : Delphi 2009 Online Resources</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-4075</link>
		<dc:creator>Paweł Głowacki : Delphi 2009 Online Resources</dc:creator>
		<pubDate>Mon, 03 Nov 2008 20:03:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-4075</guid>
		<description>[...] Craig Stuntz’s Weblog: An Enumeration of Prime Numbers with Anonymous Methods  [...]</description>
		<content:encoded><![CDATA[<p>[...] Craig Stuntz’s Weblog: An Enumeration of Prime Numbers with Anonymous Methods  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3841</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Wed, 17 Sep 2008 13:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3841</guid>
		<description>Weird. Despite having read a lot of Haskell tutorials, I never knew this was a "common" example! :)</description>
		<content:encoded><![CDATA[<p>Weird. Despite having read a lot of Haskell tutorials, I never knew this was a "common" example! <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thehangedman</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3840</link>
		<dc:creator>thehangedman</dc:creator>
		<pubDate>Wed, 17 Sep 2008 13:45:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3840</guid>
		<description>Thank you for very curious example.

One more interesting thing to mention is that actually it's neither the Sieve of Eratosthenes, nor the sieve at all. Here's the fine paper explaining why, with examples in Haskell:

http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
"A much beloved and widely used example showing the elegance and simplicity of lazy functional programming represents itself as “The Sieve of Eratosthenes”. This paper shows that this example is not the sieve, and presents an implementation that actually is."

Anyway your example is great.</description>
		<content:encoded><![CDATA[<p>Thank you for very curious example.</p>
<p>One more interesting thing to mention is that actually it&#8217;s neither the Sieve of Eratosthenes, nor the sieve at all. Here&#8217;s the fine paper explaining why, with examples in Haskell:</p>
<p><a href="http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf" rel="nofollow">http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf</a><br />
"A much beloved and widely used example showing the elegance and simplicity of lazy functional programming represents itself as “The Sieve of Eratosthenes”. This paper shows that this example is not the sieve, and presents an implementation that actually is."</p>
<p>Anyway your example is great.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 3: Fold</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3833</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 3: Fold</dc:creator>
		<pubDate>Thu, 11 Sep 2008 18:11:12 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3833</guid>
		<description>[...] to do in code.  But recall that my purpose in writing this series was to answer commentor Raymond&#8217;s request for "something like MapReduce."  So when you read this post and wonder why I&#8217;ve chosen such a roundabout method of doing [...]</description>
		<content:encoded><![CDATA[<p>[...] to do in code.  But recall that my purpose in writing this series was to answer commentor Raymond&#8217;s request for "something like MapReduce."  So when you read this post and wonder why I&#8217;ve chosen such a roundabout method of doing [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Romkin</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3825</link>
		<dc:creator>Romkin</dc:creator>
		<pubDate>Wed, 10 Sep 2008 09:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3825</guid>
		<description>Great example, thanks.
When Composite = 12 (2*2*4) cycle should be endless.</description>
		<content:encoded><![CDATA[<p>Great example, thanks.<br />
When Composite = 12 (2*2*4) cycle should be endless.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 1</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3824</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 1</dc:creator>
		<pubDate>Tue, 09 Sep 2008 16:35:40 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3824</guid>
		<description>[...] the comments to another post on the subject of Delphi 2009 generics, Raymond asked for an implementation of MapReduce.  I thought about how I might demonstrate that in the context of generics, and decided that [...]</description>
		<content:encoded><![CDATA[<p>[...] the comments to another post on the subject of Delphi 2009 generics, Raymond asked for an implementation of MapReduce.  I thought about how I might demonstrate that in the context of generics, and decided that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3810</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Tue, 02 Sep 2008 13:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3810</guid>
		<description>Raymond, I'll show something along those lines when I get the chance.</description>
		<content:encoded><![CDATA[<p>Raymond, I&#8217;ll show something along those lines when I get the chance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3809</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Tue, 02 Sep 2008 13:43:38 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3809</guid>
		<description>Jolyon, if you're seriously interested in learning why it's worthwhile to bother with functional programming styles, I recommend reading the writings of John Backus, starting with his Turing award address.</description>
		<content:encoded><![CDATA[<p>Jolyon, if you&#8217;re seriously interested in learning why it&#8217;s worthwhile to bother with functional programming styles, I recommend reading the writings of John Backus, starting with his Turing award address.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3797</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Sat, 30 Aug 2008 22:45:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3797</guid>
		<description>Oops, quite right Craig - I didn't spot the mutation of Composite.  I guess I find it easier to read code whose expression more closely resembles it's purpose:

function LargestPrimeFactor(const aComposite: Int64): Int64;
var
  i: Integer;
  primes: TEratosthenesSieve;
begin
  primes := TEratosthenesSieve.CreatePrimesTo(Round(Sqrt(aComposite + 0.0)));
  try
    for i := Pred(primes.Count) downto 0 do
      if (aComposite mod primes[i]) = 0 then
      begin
        result := primes[i];
        BREAK;
      end;
  finally
    primes.Free;
  end;
end;

(apologies for the literals-gymnastics required to co-erce an Extended value from an Int64 param - is that fixed in Delphi 2009 I wonder?)

i.e. the algorithm is - get the primes that the answer could possibly be, then find the largest one that is the answer.  The code describes the algorithm, I don't have to deduce it.

Funny thing - I thought these new language features were supposed to enable us to more clearly express intent, not unwittingly obfuscate it.

;)
 


Isn't there also a hidden cost in an enumerator based approach?

With my TEratosthenesSieve, if I have a number of operations that involve a certain sequence of primes, I only need to calculate that sequence once.  With an enumerator, won't I be re-calculating the primes over and over again (every separate time that I enumerate)?

An enumerator approach would perhaps be useful when you don't know in advance how many primes you are going to need, but even then, a non-enumerating sieve implementation could easily be extended to calculate primes on demand.

Which rather begs the question, what benefit does an enumerating approach really deliver?

Apart from providing a hook off of which to hang some new language features, I mean.

And if such questionable uses are what the language features are useful for, what use are those features, really?

I'm not saying that those features don't have practical uses, only suggesting that such examples don't actually help shed any light on what those uses are.  And concrete, practical examples do seem rather hard to come by for some reason.</description>
		<content:encoded><![CDATA[<p>Oops, quite right Craig - I didn&#8217;t spot the mutation of Composite.  I guess I find it easier to read code whose expression more closely resembles it&#8217;s purpose:</p>
<p>function LargestPrimeFactor(const aComposite: Int64): Int64;<br />
var<br />
  i: Integer;<br />
  primes: TEratosthenesSieve;<br />
begin<br />
  primes := TEratosthenesSieve.CreatePrimesTo(Round(Sqrt(aComposite + 0.0)));<br />
  try<br />
    for i := Pred(primes.Count) downto 0 do<br />
      if (aComposite mod primes[i]) = 0 then<br />
      begin<br />
        result := primes[i];<br />
        BREAK;<br />
      end;<br />
  finally<br />
    primes.Free;<br />
  end;<br />
end;</p>
<p>(apologies for the literals-gymnastics required to co-erce an Extended value from an Int64 param - is that fixed in Delphi 2009 I wonder?)</p>
<p>i.e. the algorithm is - get the primes that the answer could possibly be, then find the largest one that is the answer.  The code describes the algorithm, I don&#8217;t have to deduce it.</p>
<p>Funny thing - I thought these new language features were supposed to enable us to more clearly express intent, not unwittingly obfuscate it.</p>
<p> <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Isn&#8217;t there also a hidden cost in an enumerator based approach?</p>
<p>With my TEratosthenesSieve, if I have a number of operations that involve a certain sequence of primes, I only need to calculate that sequence once.  With an enumerator, won&#8217;t I be re-calculating the primes over and over again (every separate time that I enumerate)?</p>
<p>An enumerator approach would perhaps be useful when you don&#8217;t know in advance how many primes you are going to need, but even then, a non-enumerating sieve implementation could easily be extended to calculate primes on demand.</p>
<p>Which rather begs the question, what benefit does an enumerating approach really deliver?</p>
<p>Apart from providing a hook off of which to hang some new language features, I mean.</p>
<p>And if such questionable uses are what the language features are useful for, what use are those features, really?</p>
<p>I&#8217;m not saying that those features don&#8217;t have practical uses, only suggesting that such examples don&#8217;t actually help shed any light on what those uses are.  And concrete, practical examples do seem rather hard to come by for some reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raymond</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/08/28/37831/#comment-3793</link>
		<dc:creator>Raymond</dc:creator>
		<pubDate>Fri, 29 Aug 2008 20:08:43 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/08/28/37831#comment-3793</guid>
		<description>Thanks Craig.

You know, with all the confusion of generics, and the examples being posted of how to use them being somewhat artificial, what we really need is an implementation of something a little more concrete/real world for us all to sink our teeth into and appreciate generics with.

Something like a MapReduce would be cool!

Raymond.</description>
		<content:encoded><![CDATA[<p>Thanks Craig.</p>
<p>You know, with all the confusion of generics, and the examples being posted of how to use them being somewhat artificial, what we really need is an implementation of something a little more concrete/real world for us all to sink our teeth into and appreciate generics with.</p>
<p>Something like a MapReduce would be cool!</p>
<p>Raymond.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
