<?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/"
		>
<channel>
	<title>Comments for Lingua Computa</title>
	<atom:link href="http://nonchalantlytyped.net/blog/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://nonchalantlytyped.net/blog</link>
	<description>Compute Language &#124;&#124; Compute, Language</description>
	<lastBuildDate>Thu, 16 Aug 2012 17:48:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>Comment on Sudoku solver in C++11 by Thomas Petit</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1242</link>
		<dc:creator>Thomas Petit</dc:creator>
		<pubDate>Thu, 16 Aug 2012 17:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1242</guid>
		<description><![CDATA[What a funny coincidence ! I did the very same exercise (porting norvig sudoku solver to C++11) a few days ago. 

Here is where I deviated a bit from your solution :

1) The &quot;operator&quot;&quot; _vec&quot; part. That&#039;s quite fancy :) 
Here is a more common solution: First, overload cross() to take two std::string 

std::vector cross(const std::string&amp; s1, const std::string&amp; s2)
{
   std::vector output;
   for(char c1 : s1){
      for(char c2 : s2){
        std::string s;
        s += c1;
        s += c2;
        output.push_back(s);
      } 
   }
}

Then, you can fill unitlist this way :

for(const std::string&amp; r : {&quot;ABC&quot;, &quot;DEF&quot;, &quot;GHI&quot;}) 
   for(const std::string&amp; c : {&quot;123&quot;, &quot;456&quot;, &quot;789&quot;}
      unitlist.push_back(cross(r, c));

2) When initializing peers, you don&#039;t need to accumulate everything into a std::vector then copy it to the set of peers. You can actually directly accumulate into a std::set this way :

for(const std::string&amp; s : squares){
   peers[s] = std::accumulate(units[s].begin(), units[s].end(), std::set(),
   [&amp;](std::set&amp; peer, const std::vector&amp; v){
      for(const std::string&amp; square : v)
         if(square != s)
            peer.insert(square );
      return peer;
   });
}
]]></description>
		<content:encoded><![CDATA[<p>What a funny coincidence ! I did the very same exercise (porting norvig sudoku solver to C++11) a few days ago. </p>
<p>Here is where I deviated a bit from your solution :</p>
<p>1) The &#8220;operator&#8221;" _vec&#8221; part. That&#8217;s quite fancy <img src='http://nonchalantlytyped.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Here is a more common solution: First, overload cross() to take two std::string </p>
<p>std::vector cross(const std::string&amp; s1, const std::string&amp; s2)<br />
{<br />
   std::vector output;<br />
   for(char c1 : s1){<br />
      for(char c2 : s2){<br />
        std::string s;<br />
        s += c1;<br />
        s += c2;<br />
        output.push_back(s);<br />
      }<br />
   }<br />
}</p>
<p>Then, you can fill unitlist this way :</p>
<p>for(const std::string&amp; r : {&#8220;ABC&#8221;, &#8220;DEF&#8221;, &#8220;GHI&#8221;})<br />
   for(const std::string&amp; c : {&#8220;123&#8243;, &#8220;456&#8243;, &#8220;789&#8243;}<br />
      unitlist.push_back(cross(r, c));</p>
<p>2) When initializing peers, you don&#8217;t need to accumulate everything into a std::vector then copy it to the set of peers. You can actually directly accumulate into a std::set this way :</p>
<p>for(const std::string&#038; s : squares){<br />
   peers[s] = std::accumulate(units[s].begin(), units[s].end(), std::set(),<br />
   [&#038;](std::set&#038; peer, const std::vector&#038; v){<br />
      for(const std::string&#038; square : v)<br />
         if(square != s)<br />
            peer.insert(square );<br />
      return peer;<br />
   });<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Sudoku solver in C++11 by David Grant</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1241</link>
		<dc:creator>David Grant</dc:creator>
		<pubDate>Wed, 15 Aug 2012 04:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1241</guid>
		<description><![CDATA[&quot;Time wise, I found that the C++ implementation followed the same trend as the Python implementation. That is, most problems were solved in less than few milliseconds&quot;

I found that your C++ implementation (with -O2) takes about 4ms for the example problem you gave and about 40ms using the Python solver.]]></description>
		<content:encoded><![CDATA[<p>&#8220;Time wise, I found that the C++ implementation followed the same trend as the Python implementation. That is, most problems were solved in less than few milliseconds&#8221;</p>
<p>I found that your C++ implementation (with -O2) takes about 4ms for the example problem you gave and about 40ms using the Python solver.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Sudoku solver in C++11 by Manjunath</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1240</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Tue, 14 Aug 2012 17:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1240</guid>
		<description><![CDATA[Yep, I was wrong. I meant milli when I wrote micro. But the 160 seconds is really in seconds, not milliseconds.]]></description>
		<content:encoded><![CDATA[<p>Yep, I was wrong. I meant milli when I wrote micro. But the 160 seconds is really in seconds, not milliseconds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Sudoku solver in C++11 by David Grant</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1239</link>
		<dc:creator>David Grant</dc:creator>
		<pubDate>Tue, 14 Aug 2012 16:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1239</guid>
		<description><![CDATA[Your time units are a bit messed up. I think for microseconds you should put &quot;us&quot;. And then you say &quot;most problems were solved in less than a few microseconds&quot; where I think you meant to say &quot;milliseconds&quot;. And when you say the hard problem took 160 seconds in C++ did you mean to say millseconds?]]></description>
		<content:encoded><![CDATA[<p>Your time units are a bit messed up. I think for microseconds you should put &#8220;us&#8221;. And then you say &#8220;most problems were solved in less than a few microseconds&#8221; where I think you meant to say &#8220;milliseconds&#8221;. And when you say the hard problem took 160 seconds in C++ did you mean to say millseconds?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Sudoku solver in C++11 by Eric</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1238</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 14 Aug 2012 03:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1238</guid>
		<description><![CDATA[Did you mean to copy elements in all your for loops?  ISTR for(auto&amp; elem : container) is needed to avoid a copy. This might be part of the source of the slowly execution time.  I&#039;d expect far better results relative to python.]]></description>
		<content:encoded><![CDATA[<p>Did you mean to copy elements in all your for loops?  ISTR for(auto&amp; elem : container) is needed to avoid a copy. This might be part of the source of the slowly execution time.  I&#8217;d expect far better results relative to python.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Sudoku solver in C++11 by Arjun Nayini</title>
		<link>http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/comment-page-1/#comment-1237</link>
		<dc:creator>Arjun Nayini</dc:creator>
		<pubDate>Tue, 14 Aug 2012 02:16:30 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=381#comment-1237</guid>
		<description><![CDATA[Thanks for this.  I had hoped to actually write my own in C++ and its nice that you have written this in the latest standard.]]></description>
		<content:encoded><![CDATA[<p>Thanks for this.  I had hoped to actually write my own in C++ and its nice that you have written this in the latest standard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Lazy Lists in Different Languages by googya</title>
		<link>http://nonchalantlytyped.net/blog/2011/04/26/lazy-lists-in-different-languages/comment-page-1/#comment-1235</link>
		<dc:creator>googya</dc:creator>
		<pubDate>Mon, 16 May 2011 07:36:55 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=301#comment-1235</guid>
		<description><![CDATA[def Take(n,l)
	return [] if n==0
	return [l[&#039;first&#039;]]+Take(n-1,l[&#039;rest&#039;].call)
end


def From(n)
	{&#039;first&#039;=&gt;n,&#039;rest&#039;=&gt;lambda{From(n+1)}}
end


t=From(1)
puts Take(50,t).inspect



the codes wrote with Ruby! almost the same with Python]]></description>
		<content:encoded><![CDATA[<p>def Take(n,l)<br />
	return [] if n==0<br />
	return [l['first']]+Take(n-1,l['rest'].call)<br />
end</p>
<p>def From(n)<br />
	{&#8216;first&#8217;=&gt;n,&#8217;rest&#8217;=&gt;lambda{From(n+1)}}<br />
end</p>
<p>t=From(1)<br />
puts Take(50,t).inspect</p>
<p>the codes wrote with Ruby! almost the same with Python</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Lazy Lists in Different Languages by Manjunath</title>
		<link>http://nonchalantlytyped.net/blog/2011/04/26/lazy-lists-in-different-languages/comment-page-1/#comment-1234</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Mon, 16 May 2011 00:04:39 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=301#comment-1234</guid>
		<description><![CDATA[Thanks Don, for the better Haskell way, and others for pointing out Python generators. I wanted to keep the implementation uniform between Python, R, and C++. Yes, Python yield is definitely more natural.]]></description>
		<content:encoded><![CDATA[<p>Thanks Don, for the better Haskell way, and others for pointing out Python generators. I wanted to keep the implementation uniform between Python, R, and C++. Yes, Python yield is definitely more natural.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Lazy Lists in Different Languages by j2d2</title>
		<link>http://nonchalantlytyped.net/blog/2011/04/26/lazy-lists-in-different-languages/comment-page-1/#comment-1233</link>
		<dc:creator>j2d2</dc:creator>
		<pubDate>Sun, 15 May 2011 21:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=301#comment-1233</guid>
		<description><![CDATA[Why not use a Python generator?]]></description>
		<content:encoded><![CDATA[<p>Why not use a Python generator?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Lazy Lists in Different Languages by Don Stewart</title>
		<link>http://nonchalantlytyped.net/blog/2011/04/26/lazy-lists-in-different-languages/comment-page-1/#comment-1232</link>
		<dc:creator>Don Stewart</dc:creator>
		<pubDate>Sun, 15 May 2011 19:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://nonchalantlytyped.net/blog/?p=301#comment-1232</guid>
		<description><![CDATA[Rather than using list boxing and append, your original Haskell could be more simply expressed as:

    from n = n : from (n+1)

Though having this lazy in the list, yet strict in the accumulator, would be more sensible:

    from !n = n : from (n+1)]]></description>
		<content:encoded><![CDATA[<p>Rather than using list boxing and append, your original Haskell could be more simply expressed as:</p>
<p>    from n = n : from (n+1)</p>
<p>Though having this lazy in the list, yet strict in the accumulator, would be more sensible:</p>
<p>    from !n = n : from (n+1)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
