<?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>Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx</link><description>[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] We can now enumerate every binary tree and every arbitrary tree of a given size, and therefore we can enumerate all of them, period</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10229044</link><pubDate>Sun, 23 Oct 2011 15:06:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10229044</guid><dc:creator>PARTO</dc:creator><description>&lt;p&gt;you genius bro, could you tell me how you design your mind set to under how computer work&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10229044" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10003699</link><pubDate>Wed, 28 Apr 2010 06:43:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003699</guid><dc:creator>pete.d</dc:creator><description>&lt;p&gt;Is it just me, or do these recent articles have thematic similarity to topics found in Hofstadter's book &amp;quot;G&amp;#246;del Escher Bach&amp;quot;? I feel like it's 25 years ago and I'm exploring recursive infinities all over again!&lt;/p&gt;
&lt;p&gt;Or, wait…oh no! Am I _in_ a recursive infinity myself? Aaaaahhhh…&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003699" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10003457</link><pubDate>Tue, 27 Apr 2010 21:10:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003457</guid><dc:creator>Todd</dc:creator><description>&lt;p&gt;The program my boss told me to write?&lt;/p&gt;
&lt;p&gt;What about a program that writes the program my boss told me to write? Would the effort I'd put into specifying the program be less than the effort of writing the program? &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003457" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10003368</link><pubDate>Tue, 27 Apr 2010 18:24:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003368</guid><dc:creator>Joe</dc:creator><description>&lt;p&gt;Sorry, didn't mean to steal your thunder! &amp;nbsp;Thought you were going to move in a different direction with &amp;quot;Next time: addition causes ambiguity.&amp;quot;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003368" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10003227</link><pubDate>Tue, 27 Apr 2010 14:28:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003227</guid><dc:creator>Steve</dc:creator><description>&lt;p&gt;I feel like I'm back in Automata class.&lt;/p&gt;
&lt;p&gt;Nice post!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003227" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10002983</link><pubDate>Tue, 27 Apr 2010 06:31:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10002983</guid><dc:creator>Joe</dc:creator><description>&lt;P&gt;&amp;gt;&amp;gt; If we could find a way to enumerate all members of this grammar we’d be in good shape.&lt;/P&gt;
&lt;P&gt;Couldn't you enumerate over the number of productions? &amp;nbsp;Ie:&lt;/P&gt;
&lt;P&gt;Given: &amp;nbsp;A grammar and a string representing a possible result of (n) productions&lt;/P&gt;
&lt;P&gt;Desired: &amp;nbsp;A list of strings containing all possible results of applying one further production&lt;/P&gt;
&lt;P&gt;IEnumerable&amp;lt;string&amp;gt; GetProductions(Grammar G, string Input)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return from nonTerm in G.FindNonTerminals(Input) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // nonTerm: label and position of NonTerminal in Input&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from rule in G.GetRules(nonTerm.Label)&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// grammar rules having nonTerm.Label as their left hand side [ Rules in CFG: &amp;nbsp;NT =&amp;gt; (NT | T)* ]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select G.ApplyProduction(Input, nonTerm, rule.Replacement); // string substitution of nonTerm.Label at nonTerm.Position with rule.Replacement in Input&lt;BR&gt;}&lt;BR&gt;IEnumerable&amp;lt;string&amp;gt; GetProductions(Grammar G, IEnumerable&amp;lt;string&amp;gt; Inputs)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; &amp;nbsp;return Inputs.SelectMany((input) =&amp;gt; GetProductions(G, input));&lt;BR&gt;}&lt;BR&gt;IEnumerable&amp;lt;string&amp;gt; AllProductions(Grammar G, int Length)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; &amp;nbsp;if(Length == 0) return new string[] { G.StartSymbol };&lt;BR&gt;&amp;nbsp; &amp;nbsp;return GetProductions(G, AllProductions(G, Length - 1));&lt;BR&gt;}&lt;BR&gt;IEnumerable&amp;lt;string&amp;gt; AllSentences(Grammar G, int Length)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; &amp;nbsp;return from value in AllProductions(G, Length) where G.IsTerminated(value);&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;For this grammar we would have:&lt;/P&gt;
&lt;P&gt;n = 0: &amp;nbsp;S&lt;/P&gt;
&lt;P&gt;n = 1: { X } , { }&lt;/P&gt;
&lt;P&gt;n = 2: { X X } , { { X } }, { { } }&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;DIV class=yellowbox&gt;
&lt;P&gt;You have prematurely anticipated my denouement, Commander. -- 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=10002983" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10002978</link><pubDate>Tue, 27 Apr 2010 06:21:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10002978</guid><dc:creator>Eamon Nerbonne</dc:creator><description>&lt;p&gt;Great twist on the last post, this! :-)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10002978" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10002875</link><pubDate>Tue, 27 Apr 2010 00:58:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10002875</guid><dc:creator>Lucas McCoy</dc:creator><description>&lt;p&gt;The first example you gave: `{{}{{}}}` reminds me of a plugin I use every day (in Gedit). &lt;/p&gt;
&lt;p&gt;It's called zen-coding, basically you type something like: &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;div#nameOfMyCalss&amp;gt;ul.nameOfMyId&amp;gt;li*5&amp;gt;a&lt;/p&gt;
&lt;p&gt;and it turns it into this (not sure if this will show up since it's HTML so I'll replace &amp;lt;&amp;gt; with these {}):&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{div class=&amp;quot;nameOfMyClass&amp;quot;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ul id=&amp;quot;nameOfMyId&amp;quot;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{li}{/li}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{li}{/li}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{li}{/li}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{li}{/li}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{li}{/li}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{/ul}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{/div}&lt;/p&gt;
&lt;p&gt;Anyway thats what it made me think of. Also after reading your post I now want to read through some of their code and see how they implemented it. &lt;/p&gt;
&lt;p&gt;Awesome post BTW! &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10002875" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10002777</link><pubDate>Mon, 26 Apr 2010 21:07:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10002777</guid><dc:creator>Bahbar2</dc:creator><description>&lt;p&gt;Err... you're mixing up nonterminals and terminals in the last part. You always end up with 7 _terminals_. Yeah, I'm not the one who swore.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10002777" width="1" height="1"&gt;</description></item><item><title>re: Every Program There Is, Part One</title><link>http://blogs.msdn.com/b/ericlippert/archive/2010/04/26/every-program-there-is-part-one.aspx#10002776</link><pubDate>Mon, 26 Apr 2010 21:04:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10002776</guid><dc:creator>Bahbar</dc:creator><description>&lt;p&gt;@TheCPUWizard: Well, the &amp;quot;nothing&amp;quot; concept shows up quite often in BNFs. But since Eric called this CFG, I guess I'll let him define what's valid. That said, Eric, there are _3_ non-terminals, not 2. I'm done picking nits now. I swear.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10002776" width="1" height="1"&gt;</description></item></channel></rss>