<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Differences and Intersections on Infinite Lists</title>
	<atom:link href="http://techguyinmidtown.com/2008/04/30/differences-and-intersections-on-infinite-lists/feed/" rel="self" type="application/rss+xml" />
	<link>http://techguyinmidtown.com/2008/04/30/differences-and-intersections-on-infinite-lists/</link>
	<description>the notebook of a computer scientist living in midtown manhattan</description>
	<lastBuildDate>Sun, 11 Dec 2011 20:21:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: harfga</title>
		<link>http://techguyinmidtown.com/2008/04/30/differences-and-intersections-on-infinite-lists/#comment-5</link>
		<dc:creator><![CDATA[harfga]]></dc:creator>
		<pubDate>Fri, 02 May 2008 01:04:35 +0000</pubDate>
		<guid isPermaLink="false">http://techguyinmidtown.wordpress.com/?p=9#comment-5</guid>
		<description><![CDATA[Hi Brent,

Thanks for taking the time to reply.  I wrote up another post expanding upon the approach that you suggest.]]></description>
		<content:encoded><![CDATA[<p>Hi Brent,</p>
<p>Thanks for taking the time to reply.  I wrote up another post expanding upon the approach that you suggest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Another approach to infinite set operations &#171; tech guy in midtown</title>
		<link>http://techguyinmidtown.com/2008/04/30/differences-and-intersections-on-infinite-lists/#comment-4</link>
		<dc:creator><![CDATA[Another approach to infinite set operations &#171; tech guy in midtown]]></dc:creator>
		<pubDate>Fri, 02 May 2008 01:03:01 +0000</pubDate>
		<guid isPermaLink="false">http://techguyinmidtown.wordpress.com/?p=9#comment-4</guid>
		<description><![CDATA[[...] tech guy in midtown the notebook of a computer scientist living in midtown manhattan      &#171; Differences and Intersections on Infinite&#160;Lists. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] tech guy in midtown the notebook of a computer scientist living in midtown manhattan      &laquo; Differences and Intersections on Infinite&nbsp;Lists. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brent</title>
		<link>http://techguyinmidtown.com/2008/04/30/differences-and-intersections-on-infinite-lists/#comment-3</link>
		<dc:creator><![CDATA[Brent]]></dc:creator>
		<pubDate>Thu, 01 May 2008 20:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://techguyinmidtown.wordpress.com/?p=9#comment-3</guid>
		<description><![CDATA[I like this approach.  The one issue I have with it is that you may not like the restriction of having to decide *in advance* how far you want the difference or intersection functions to look before stopping.  Also, if and when they do stop, there&#039;s a lot of information that&#039;s lost: although you may know that, say, infDiff went through 10 iterations before giving up, you won&#039;t know anything about the list elements it discarded along the way.

Here&#039;s a slight variation I thought of which solves these problems.  Define a special list type that looks like this:

data StutterList a = Nil &#124; Cons a (StutterList a) &#124; AtLeast a (StutterList a)

The value (Cons x xs) of course tells you that the first element in the list is x, and the remaining elements are given by xs.  Since we&#039;re dealing with sorted lists we also know that all the elements of xs are at least x.  The value (AtLeast x xs), on the other hand, just says that all the values in the list are at least x, without telling you what the first element is (it might be x, or it might be something bigger; we just don&#039;t know yet).  

Using this type, it is not hard to write infDiff and infIntersect in a way that is guaranteed not to go into infinite recursion, even when called on infinite lists, since every recursive call will be guarded by a constructor (a Cons constructor, in the case of finding a value which is actually contained in the output list, and an AtLeast constructor, in the case of finding one that isn&#039;t).  More importantly, this means that code calling infDiff and infIntersect doesn&#039;t have to decide up front how far to look -- it can decide on the fly, possibly making use of knowledge about the size of potential remaining list elements (i.e., it could keep running until being sure that any remaining elements are greater than 100), or data computed from the initial elements of the result list, and so on.  I leave writing such implementations as an exercise. =)]]></description>
		<content:encoded><![CDATA[<p>I like this approach.  The one issue I have with it is that you may not like the restriction of having to decide *in advance* how far you want the difference or intersection functions to look before stopping.  Also, if and when they do stop, there&#8217;s a lot of information that&#8217;s lost: although you may know that, say, infDiff went through 10 iterations before giving up, you won&#8217;t know anything about the list elements it discarded along the way.</p>
<p>Here&#8217;s a slight variation I thought of which solves these problems.  Define a special list type that looks like this:</p>
<p>data StutterList a = Nil | Cons a (StutterList a) | AtLeast a (StutterList a)</p>
<p>The value (Cons x xs) of course tells you that the first element in the list is x, and the remaining elements are given by xs.  Since we&#8217;re dealing with sorted lists we also know that all the elements of xs are at least x.  The value (AtLeast x xs), on the other hand, just says that all the values in the list are at least x, without telling you what the first element is (it might be x, or it might be something bigger; we just don&#8217;t know yet).  </p>
<p>Using this type, it is not hard to write infDiff and infIntersect in a way that is guaranteed not to go into infinite recursion, even when called on infinite lists, since every recursive call will be guarded by a constructor (a Cons constructor, in the case of finding a value which is actually contained in the output list, and an AtLeast constructor, in the case of finding one that isn&#8217;t).  More importantly, this means that code calling infDiff and infIntersect doesn&#8217;t have to decide up front how far to look &#8212; it can decide on the fly, possibly making use of knowledge about the size of potential remaining list elements (i.e., it could keep running until being sure that any remaining elements are greater than 100), or data computed from the initial elements of the result list, and so on.  I leave writing such implementations as an exercise. =)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

