<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx</link><description>Suppose you’ve got a sequence of Foos and you want to project from that a sequences of Bars. That’s straightforward using LINQ: 
 IEnumerable&amp;lt;Bars&amp;gt; bars = from foo in foos select MakeBar(foo); 
 or, without the query sugar: 
 IEnumerable&amp;lt;Bars&amp;gt;</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9988757</link><pubDate>Thu, 01 Apr 2010 10:52:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9988757</guid><dc:creator>Neil</dc:creator><description>&lt;p&gt;I don't claim to know how iterators work in C#, but the way another language implementation throws an iteration exception when you run off the end of the list allows you to simplify the zip operation something like this:&lt;/p&gt;
&lt;p&gt;function zip(left, right) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;for (;;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;yield [left.next(), right.next()];&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9988757" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9629861</link><pubDate>Wed, 20 May 2009 01:08:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9629861</guid><dc:creator>Greg</dc:creator><description>&lt;p&gt;The funny thing is that the code to use the zip join is overly expensive to maintain and develop for in production quality commercial software. &amp;nbsp;The cost is not really in lines of code but in the mental effort needed to understand and verify what is actually happening (easy to verify in a single 10 line chunk but not easy to do when you have 500+ methods using similar coding constructs).&lt;/p&gt;
&lt;p&gt;It fails the Monday morning, did not sleep the night before, code takes too long to understand test (even for code you wrote a week ago).&lt;/p&gt;
&lt;p&gt;list ret = new list()&lt;/p&gt;
&lt;p&gt;int x = max( list1.length, list2.length )&lt;/p&gt;
&lt;p&gt;for (int ctr = 0; ctr &amp;lt; x; ctr++)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;element o1 = o2 = null&lt;/p&gt;
&lt;p&gt; &amp;nbsp;if (x &amp;lt; list1.length) &amp;nbsp; &amp;nbsp; o1 = list1[x];&lt;/p&gt;
&lt;p&gt; &amp;nbsp;if (x &amp;lt; list2.length) &amp;nbsp; &amp;nbsp; o2 = list2[x];&lt;/p&gt;
&lt;p&gt; &amp;nbsp;e = ret.addnew(o1, o2)&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Concentrating effort on better high level algorithms, data base organization and project organization will yield many times more productivity.&lt;/p&gt;
&lt;p&gt;The straight line sequential code is easier to take over and maintain by a developer unfamiliar with the rest of the application's code.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9629861" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9617269</link><pubDate>Fri, 15 May 2009 01:42:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9617269</guid><dc:creator>Daniel Earwicker</dc:creator><description>&lt;p&gt;Re: Unfold, thanks! I already wrote my own in a simpler form where the transform part is left out (just stick a Select after it if you need that). I guess everyone using Linq is writing their own slightly different version of it.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9617269" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9602170</link><pubDate>Mon, 11 May 2009 12:46:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9602170</guid><dc:creator>Pop Catalin</dc:creator><description>&lt;p&gt;Daniel Lehmann wrote:&lt;/p&gt;
&lt;p&gt;&amp;gt; That's exactly the reason why I think Scala made the right decision to put Linq-similar things in libraries and instead create an expandable language. While Linq surely feels nice it can't be extended by anyone except the C# developers...&lt;/p&gt;
&lt;p&gt;Linq is a pattern, anyone can adhere to the Linq pattern, which means that the implementation part of Linq is extensible at the core, the only part of Linq that is not extensible is the comprehension syntax (you can't add new comprehension keywords, but you can make the comprehension syntax translate to entirely different &amp;quot;member&amp;quot; calls, usually methods). Other than adding new language keywords, you can extend Linq in any possible way imaginable (you can completely replace Linq to SQL, or Linq to XML, or Linq to Objects with your implementation, or simply mix other implementations with your own selectively)... &lt;/p&gt;
&lt;p&gt;The comprehension syntax in linq is simply a loose pattern matching (that works by translating to appropriate &amp;quot;member&amp;quot; calls (not just methods), using regular member resolution rules), the rest of Linq is straight forward libraries with standard CLR types that adhere to the linq pattern, and which can be implemented by anyone.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9602170" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9600624</link><pubDate>Sun, 10 May 2009 18:11:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600624</guid><dc:creator>Daniel Earwicker</dc:creator><description>&lt;P&gt;Eric, will there be an Unfold in version 4?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;Not to my knowledge. But it would&amp;nbsp;be&amp;nbsp;trivial to write such a beast yourself. How about this?&lt;/P&gt;
&lt;P&gt;static IE&amp;lt;T&amp;gt; Unfold&amp;lt;S, T&amp;gt;(this S state, Func&amp;lt;S, bool&amp;gt; done, Func&amp;lt;S, S&amp;gt; next, Func&amp;lt;S, T&amp;gt; transform)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;while (true)&amp;nbsp;&lt;BR&gt;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield return transform(state); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (done(state)) yield break;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; state = next(state); &lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;-- Eric&lt;/P&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600624" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9600249</link><pubDate>Sun, 10 May 2009 10:55:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600249</guid><dc:creator>Pavel Minaev [MSFT]</dc:creator><description>&lt;p&gt;Scala still has syntactic sugar for query comprehensions, no? So it exposes &amp;quot;filter&amp;quot; and &amp;quot;map&amp;quot; already, and in a non-extensible way, too.&lt;/p&gt;
&lt;p&gt;Sure, C# goes further than that, with joins and ordering, but fundamentally there's no difference. You still want the common operations to be sugared, the only question is where to draw the dividing line.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600249" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9598942</link><pubDate>Sat, 09 May 2009 12:49:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9598942</guid><dc:creator>Daniel Lehmann</dc:creator><description>&lt;p&gt;&amp;quot;However, we decided that adding a query syntax for a relatively obscure operation that is not actually supported by most relational databases was not worth the cost of complicating the grammar and the syntactic translation rules.&amp;quot;&lt;/p&gt;
&lt;p&gt;That's exactly the reason why I think Scala made the right decision to put Linq-similar things in libraries and instead create an expandable language. While Linq surely feels nice it can't be extended by anyone except the C# developers...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9598942" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9598618</link><pubDate>Sat, 09 May 2009 08:04:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9598618</guid><dc:creator>Lucas</dc:creator><description>&lt;p&gt;Thanks Eric!! I use iterators all the time and was not aware that my null checks (just like in your psychic debugging example) where being deferred... doh!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9598618" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9597830</link><pubDate>Sat, 09 May 2009 00:30:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9597830</guid><dc:creator>Lucas</dc:creator><description>&lt;P&gt;Why did you choose a 2-method implementation? What is the need for the private ZipIterator()? Can't you yield return from Zip()?&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;Good question. I covered that already a while back: &lt;A href="http://blogs.msdn.com/ericlippert/archive/tags/Psychic+Debugging/default.aspx"&gt;http://blogs.msdn.com/ericlippert/archive/tags/Psychic+Debugging/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;-- Eric&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9597830" width="1" height="1"&gt;</description></item><item><title>re: Zip Me Up</title><link>http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx#9597692</link><pubDate>Fri, 08 May 2009 23:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9597692</guid><dc:creator>Ed</dc:creator><description>&lt;p&gt;Reviewing what I learned from your excellent post on naming things, I have to admit that Andrey Shchekin's comment is spot on.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9597692" width="1" height="1"&gt;</description></item></channel></rss>