<?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: Building a Generic Statistics Library, Part 1: Interface</title>
	<atom:link href="http://blogs.teamb.com/craigstuntz/2008/09/09/37833/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/</link>
	<description>C# • Delphi • Entity Framework • Functional Programming • InterBase • MVC • .NET • Web</description>
	<pubDate>Wed, 17 Mar 2010 04:30:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Implementing Memoize in Delphi 2009</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3936</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Implementing Memoize in Delphi 2009</dc:creator>
		<pubDate>Wed, 01 Oct 2008 18:30:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3936</guid>
		<description>[...] My last series on Delphi 2009&#8217;s generics was self-consciously investigating a corner case.  This post, however, is going to bring us back to Earth very quickly, so prepare for a steep descent!  I&#8217;m going to implement a useful, higher-order function, Memoize, using Delphi 2009&#8217;s generics and anonymous methods. [...]</description>
		<content:encoded><![CDATA[<p>[...] My last series on Delphi 2009&#8217;s generics was self-consciously investigating a corner case.  This post, however, is going to bring us back to Earth very quickly, so prepare for a steep descent!  I&#8217;m going to implement a useful, higher-order function, Memoize, using Delphi 2009&#8217;s generics and anonymous methods. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 5: Implementation</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3890</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 5: Implementation</dc:creator>
		<pubDate>Wed, 24 Sep 2008 15:06:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3890</guid>
		<description>[...] Delphi 2009’s new generic types.  If you’re new to the series, you might want to start with the first post. Having implemented the functions FoldL and Map, and having used FoldL to implement Count and Sum, [...]</description>
		<content:encoded><![CDATA[<p>[...] Delphi 2009’s new generic types.  If you’re new to the series, you might want to start with the first post. Having implemented the functions FoldL and Map, and having used FoldL to implement Count and Sum, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 4: Map</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3845</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 4: Map</dc:creator>
		<pubDate>Wed, 17 Sep 2008 23:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3845</guid>
		<description>[...] 2009&#8217;s new generic types.  If you&#8217;re new to the series, you might want to start with the first post.  Today I&#8217;m going to discuss the second higher-order function that the library uses [...]</description>
		<content:encoded><![CDATA[<p>[...] 2009&#8217;s new generic types.  If you&#8217;re new to the series, you might want to start with the first post.  Today I&#8217;m going to discuss the second higher-order function that the library uses [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3837</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Sat, 13 Sep 2008 01:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3837</guid>
		<description>Fair enough - for some reason that explanation of the return type didn't register.

As far as op constraints in generics are concerned, I'll need to have word with my .NET colleagues all of whom seem to be labouring under a misunderstanding of .NET generics.

(I don't doubt you - a quick google seems to confirm that op constraints are also not supported in .NET)</description>
		<content:encoded><![CDATA[<p>Fair enough - for some reason that explanation of the return type didn&#8217;t register.</p>
<p>As far as op constraints in generics are concerned, I&#8217;ll need to have word with my .NET colleagues all of whom seem to be labouring under a misunderstanding of .NET generics.</p>
<p>(I don&#8217;t doubt you - a quick google seems to confirm that op constraints are also not supported in .NET)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3836</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Thu, 11 Sep 2008 19:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3836</guid>
		<description>Raymond, my first attempt at implementing IEnumerable&#60;T&#62; failed miserably. It's very likely my own error, but I was using a beta version of the compiler at the time, and I didn't have any RTL example to follow, so I didn't really pursue the problem.  It's something I intend to return to later on.</description>
		<content:encoded><![CDATA[<p>Raymond, my first attempt at implementing IEnumerable&lt;T&gt; failed miserably. It&#8217;s very likely my own error, but I was using a beta version of the compiler at the time, and I didn&#8217;t have any RTL example to follow, so I didn&#8217;t really pursue the problem.  It&#8217;s something I intend to return to later on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raymond</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3835</link>
		<dc:creator>Raymond</dc:creator>
		<pubDate>Thu, 11 Sep 2008 19:55:18 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3835</guid>
		<description>Craig,

Thanks for taking the time out to work up this series of posts. 

You mention that neither Tlist nor TEnumerable implement IEnumerable in the RTL. 

Would this be hard to add as a modification to a local version of the RTL source?

Yes, I know everyone will say that will break things in deployed and third party packages etc, and they'd be right. But we don't use packages, and we recompile from source all our third party components so, so it's not a problem for us :-)

Raymond.</description>
		<content:encoded><![CDATA[<p>Craig,</p>
<p>Thanks for taking the time out to work up this series of posts. </p>
<p>You mention that neither Tlist nor TEnumerable implement IEnumerable in the RTL. </p>
<p>Would this be hard to add as a modification to a local version of the RTL source?</p>
<p>Yes, I know everyone will say that will break things in deployed and third party packages etc, and they&#8217;d be right. But we don&#8217;t use packages, and we recompile from source all our third party components so, so it&#8217;s not a problem for us <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Raymond.</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/09/09/37833/#comment-3831</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Building a Generic Statistics Library, Part 3: Fold</dc:creator>
		<pubDate>Thu, 11 Sep 2008 18:03:28 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3831</guid>
		<description>[...] This post is the third in a series on building a statistics library using Delphi 2009&#8217;s generic types.  If you&#8217;re new to the series, you might want to start at the beginning. [...]</description>
		<content:encoded><![CDATA[<p>[...] This post is the third in a series on building a statistics library using Delphi 2009&#8217;s generic types.  If you&#8217;re new to the series, you might want to start at the beginning. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3829</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Thu, 11 Sep 2008 12:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3829</guid>
		<description>No, .NET does not have the operator constraints, per se.  It does have IComparable&#60;T&#62;, which is useful for operators like &#60; or ==, but, off the top of my head, I don't know of any way to do +.

Regarding why Average returns T and not Double (or better still, R, an arbitrary result type), I explained that in the post:

&lt;blockquote&gt;In order to make the code I’m going to show simpler, I’ll use the same type argument for the input and output.  In other words, if the function is passed a list of integers, it will return the average as an integer.  If it’s passed a list of doubles, it will return the average as a double.  This is probably not ideal for a general-purpose statistical library, but, for the purposes of this demo, it makes the code quite a bit easier to understand.&lt;/blockquote&gt;

Raymond asked for a demonstration of something like MapReduce.  I'm happy to oblige, but it's already turning into one of the longest answers to a question that I've ever posted on this blog.  So I'm trying to steer around features like this which would make it even longer.</description>
		<content:encoded><![CDATA[<p>No, .NET does not have the operator constraints, per se.  It does have IComparable&lt;T&gt;, which is useful for operators like &lt; or ==, but, off the top of my head, I don&#8217;t know of any way to do +.</p>
<p>Regarding why Average returns T and not Double (or better still, R, an arbitrary result type), I explained that in the post:</p>
<blockquote><p>In order to make the code I’m going to show simpler, I’ll use the same type argument for the input and output.  In other words, if the function is passed a list of integers, it will return the average as an integer.  If it’s passed a list of doubles, it will return the average as a double.  This is probably not ideal for a general-purpose statistical library, but, for the purposes of this demo, it makes the code quite a bit easier to understand.</p></blockquote>
<p>Raymond asked for a demonstration of something like MapReduce.  I&#8217;m happy to oblige, but it&#8217;s already turning into one of the longest answers to a question that I&#8217;ve ever posted on this blog.  So I&#8217;m trying to steer around features like this which would make it even longer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3828</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 11 Sep 2008 03:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3828</guid>
		<description>AAARRGH!  Why did no one realise that using &#60; and &#62; in generics syntax would make comments in technical blogs a nightmare!!!!</description>
		<content:encoded><![CDATA[<p>AAARRGH!  Why did no one realise that using &lt; and &gt; in generics syntax would make comments in technical blogs a nightmare!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blogs.teamb.com/craigstuntz/2008/09/09/37833/#comment-3827</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 11 Sep 2008 02:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/2008/09/09/37833#comment-3827</guid>
		<description>I am told that .NET has operator constraints.  If so, it's a real shame that didn't find it's way into the Delphi Win32 generics implementation.

Too many concrete applications of generics, outside of simple containers, would seem to require a greater richness than Delphi 2009 generics currently provide.

I'm beginning to think that an approach based more on C++ templates would have been preferable (or at least a useful addition, if not instead of).

A slight tweak to the syntax might yet enable this:

Average(aData: IEnumerable): Double;

For which:

  Average(..);

would be fine but

  Average(..);

would fail to compile (when the compiler attempts to emit : sum of strings divided by number of strings).

The operator constraints approach could deal with things in this case more cleanly though:

Average(aData: IEnumerable): Double;


This is an off-the-cuff speculation at the sort of contraints specification that might be needed (i.e. T supports Addition of T yielding T and division by T yielding Double).


Assuming that Addition and Division indicate the calculation of a mean average, the result is surely a floating point of one form or another, not T.  I've simply opted for Double in my decls above.</description>
		<content:encoded><![CDATA[<p>I am told that .NET has operator constraints.  If so, it&#8217;s a real shame that didn&#8217;t find it&#8217;s way into the Delphi Win32 generics implementation.</p>
<p>Too many concrete applications of generics, outside of simple containers, would seem to require a greater richness than Delphi 2009 generics currently provide.</p>
<p>I&#8217;m beginning to think that an approach based more on C++ templates would have been preferable (or at least a useful addition, if not instead of).</p>
<p>A slight tweak to the syntax might yet enable this:</p>
<p>Average(aData: IEnumerable): Double;</p>
<p>For which:</p>
<p>  Average(..);</p>
<p>would be fine but</p>
<p>  Average(..);</p>
<p>would fail to compile (when the compiler attempts to emit : sum of strings divided by number of strings).</p>
<p>The operator constraints approach could deal with things in this case more cleanly though:</p>
<p>Average(aData: IEnumerable): Double;</p>
<p>This is an off-the-cuff speculation at the sort of contraints specification that might be needed (i.e. T supports Addition of T yielding T and division by T yielding Double).</p>
<p>Assuming that Addition and Division indicate the calculation of a mean average, the result is surely a floating point of one form or another, not T.  I&#8217;ve simply opted for Double in my decls above.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
