<?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:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments for What the hell, what do I know?</title>
	<atom:link href="http://wthwdik.wordpress.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://wthwdik.wordpress.com</link>
	<description>A self-maieutic blog by Nicola Musatti</description>
	<lastBuildDate>Sun, 08 Nov 2009 18:16:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on insert_separator by nmusatti</title>
		<link>http://wthwdik.wordpress.com/2008/06/25/insert_separator/#comment-54</link>
		<dc:creator>nmusatti</dc:creator>
		<pubDate>Sun, 08 Nov 2009 18:16:05 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=36#comment-54</guid>
		<description>Thank you for your explanation.

You&#039;re right again about my C# solution; the boolean variable is indeed ugly, but on the other hand it makes it possible to represent the same idea in the same way in all the examples.

There are situations where there isn&#039;t any superior alternative: for instance C++ iterators do not have a notion of first element so in order to check for it an additional loop control variable would be required, so as not to move the starting iterator.</description>
		<content:encoded><![CDATA[<p>Thank you for your explanation.</p>
<p>You&#8217;re right again about my C# solution; the boolean variable is indeed ugly, but on the other hand it makes it possible to represent the same idea in the same way in all the examples.</p>
<p>There are situations where there isn&#8217;t any superior alternative: for instance C++ iterators do not have a notion of first element so in order to check for it an additional loop control variable would be required, so as not to move the starting iterator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on insert_separator by xpmatteo</title>
		<link>http://wthwdik.wordpress.com/2008/06/25/insert_separator/#comment-53</link>
		<dc:creator>xpmatteo</dc:creator>
		<pubDate>Sun, 08 Nov 2009 17:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=36#comment-53</guid>
		<description>Ah yes, the inject trick.  Inject takes a block of code and gives it two parameters; the first is the accumulator and the second is each element of the array in turn.  Functional programming people call it &quot;fold&quot;.  

[1,2,3].inject {&#124;sum, element&#124; sum + element } gives 6.  

When the array is empty, inject returns nil.  So I add the 

... &#124;&#124; &quot; 

to cover that case.  If inject returns nil, we return empty string.

So there are two &quot;ifs&quot; in the second solution, the first is in the &quot;&#124;&#124;&quot; which treats the special case of empty array, and the second is hidden in &quot;inject&quot; which will just return the first element if the array is a singleton.  

I think your C# solution would be prettier if you used 

if (e == elements.first) 

in place of the ugly boolean flag.  You need a test for the first case, anyways.  One way is to test if the accumulator is empty, the other is to test if the current array element is the first.

Here&#039;s another solution that is more similar to yours.  The intertwine function captures the behaviour of joining and might be useful in other places.

require &quot;test/unit&quot;

def intertwine(array, separator)
  for element in array 
    yield separator unless element == array.first
    yield element
  end
end

def join(array, separator)
  result = &quot;&quot;
  intertwine(array, separator) do &#124;element&#124; 
    result += element 
  end
  result
end

class TestLibraryFileName &lt; Test::Unit::TestCase
  def test_case_name
    assert_equal &quot;&quot;, join([], &quot;, &quot;)
    assert_equal &quot;x&quot;, join([&quot;x&quot;], &quot;, &quot;)
    assert_equal &quot;x, y&quot;, join([&quot;x&quot;, &quot;y&quot;], &quot;, &quot;)
  end
end</description>
		<content:encoded><![CDATA[<p>Ah yes, the inject trick.  Inject takes a block of code and gives it two parameters; the first is the accumulator and the second is each element of the array in turn.  Functional programming people call it &#8220;fold&#8221;.  </p>
<p>[1,2,3].inject {|sum, element| sum + element } gives 6.  </p>
<p>When the array is empty, inject returns nil.  So I add the </p>
<p>&#8230; || &#8221; </p>
<p>to cover that case.  If inject returns nil, we return empty string.</p>
<p>So there are two &#8220;ifs&#8221; in the second solution, the first is in the &#8220;||&#8221; which treats the special case of empty array, and the second is hidden in &#8220;inject&#8221; which will just return the first element if the array is a singleton.  </p>
<p>I think your C# solution would be prettier if you used </p>
<p>if (e == elements.first) </p>
<p>in place of the ugly boolean flag.  You need a test for the first case, anyways.  One way is to test if the accumulator is empty, the other is to test if the current array element is the first.</p>
<p>Here&#8217;s another solution that is more similar to yours.  The intertwine function captures the behaviour of joining and might be useful in other places.</p>
<p>require &#8220;test/unit&#8221;</p>
<p>def intertwine(array, separator)<br />
  for element in array<br />
    yield separator unless element == array.first<br />
    yield element<br />
  end<br />
end</p>
<p>def join(array, separator)<br />
  result = &#8220;&#8221;<br />
  intertwine(array, separator) do |element|<br />
    result += element<br />
  end<br />
  result<br />
end</p>
<p>class TestLibraryFileName &lt; Test::Unit::TestCase<br />
  def test_case_name<br />
    assert_equal &quot;&quot;, join([], &quot;, &quot;)<br />
    assert_equal &quot;x&quot;, join([&quot;x&quot;], &quot;, &quot;)<br />
    assert_equal &quot;x, y&quot;, join([&quot;x&quot;, &quot;y&quot;], &quot;, &quot;)<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on insert_separator by nmusatti</title>
		<link>http://wthwdik.wordpress.com/2008/06/25/insert_separator/#comment-52</link>
		<dc:creator>nmusatti</dc:creator>
		<pubDate>Sun, 08 Nov 2009 16:12:43 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=36#comment-52</guid>
		<description>Hi Matt,
You&#039;re right of course. I was more concerned with making my point than with writing production quality code.
Your first solution is more compact than mines whenever you actually do have an underlying accumulator, otherwise you need different means for distinguishing the first iteration.
I have to say that I&#039;m not sure I understand the details of your second solution. Would you care to explain?</description>
		<content:encoded><![CDATA[<p>Hi Matt,<br />
You&#8217;re right of course. I was more concerned with making my point than with writing production quality code.<br />
Your first solution is more compact than mines whenever you actually do have an underlying accumulator, otherwise you need different means for distinguishing the first iteration.<br />
I have to say that I&#8217;m not sure I understand the details of your second solution. Would you care to explain?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on insert_separator by xpmatteo</title>
		<link>http://wthwdik.wordpress.com/2008/06/25/insert_separator/#comment-51</link>
		<dc:creator>xpmatteo</dc:creator>
		<pubDate>Sun, 08 Nov 2009 07:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=36#comment-51</guid>
		<description>Hi Nick,

your first solution fails when the input array is empty!

My next-to-favourite solution (in Ruby) would be

def join(array, separator)
  result = &quot;&quot;
  for element in array
    result += separator unless result.empty?
    result += element
  end
  result
end

And this would be the algorithm I would use in old school languages like Java or C++.  But if you have nice &quot;higher order&quot; methods in your language, you can shorten it to something as cool as:

def join(array, separator)
  array.inject {&#124;a,b&#124; a + separator + b} &#124;&#124; &quot;&quot;
end</description>
		<content:encoded><![CDATA[<p>Hi Nick,</p>
<p>your first solution fails when the input array is empty!</p>
<p>My next-to-favourite solution (in Ruby) would be</p>
<p>def join(array, separator)<br />
  result = &#8220;&#8221;<br />
  for element in array<br />
    result += separator unless result.empty?<br />
    result += element<br />
  end<br />
  result<br />
end</p>
<p>And this would be the algorithm I would use in old school languages like Java or C++.  But if you have nice &#8220;higher order&#8221; methods in your language, you can shorten it to something as cool as:</p>
<p>def join(array, separator)<br />
  array.inject {|a,b| a + separator + b} || &#8220;&#8221;<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Does anybody here remember&#8230; Live Wire? by nmusatti</title>
		<link>http://wthwdik.wordpress.com/2008/11/22/does-anybody-here-remember-live-wire/#comment-48</link>
		<dc:creator>nmusatti</dc:creator>
		<pubDate>Tue, 31 Mar 2009 21:53:24 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=65#comment-48</guid>
		<description>I recently found a Live Wire video on You Tube: http://www.youtube.com/watch?v=9SsZaxJRgQ4</description>
		<content:encoded><![CDATA[<p>I recently found a Live Wire video on You Tube: <a href="http://www.youtube.com/watch?v=9SsZaxJRgQ4" rel="nofollow">http://www.youtube.com/watch?v=9SsZaxJRgQ4</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Rasputin ha chiuso by Per i nostalgici di Rasputin Dischi &#171; What the hell, what do I know?</title>
		<link>http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-47</link>
		<dc:creator>Per i nostalgici di Rasputin Dischi &#171; What the hell, what do I know?</dc:creator>
		<pubDate>Sun, 16 Nov 2008 15:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-47</guid>
		<description>[...] Facebook tutto per noi! Dal momento che ogni volta che controllo qualcun altro è capitato sul mio post a proposito di Rasputin, ho pensato che sarebbe stato divertente vedere chi siamo e quanti [...]</description>
		<content:encoded><![CDATA[<p>[...] Facebook tutto per noi! Dal momento che ogni volta che controllo qualcun altro è capitato sul mio post a proposito di Rasputin, ho pensato che sarebbe stato divertente vedere chi siamo e quanti [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Rasputin ha chiuso by nmusatti</title>
		<link>http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-46</link>
		<dc:creator>nmusatti</dc:creator>
		<pubDate>Sun, 16 Nov 2008 14:45:26 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-46</guid>
		<description>Dal momento che siete in tanti a leggere questo post ho pensato di provare a trovarci su Facebook: http://www.facebook.com/group.php?gid=35884783309&amp;ref=mf</description>
		<content:encoded><![CDATA[<p>Dal momento che siete in tanti a leggere questo post ho pensato di provare a trovarci su Facebook: <a href="http://www.facebook.com/group.php?gid=35884783309&amp;ref=mf" rel="nofollow">http://www.facebook.com/group.php?gid=35884783309&amp;ref=mf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Boost 1.37 is out by Anonymous</title>
		<link>http://wthwdik.wordpress.com/2008/11/04/boost-137-is-out/#comment-45</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 05 Nov 2008 00:35:02 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/?p=52#comment-45</guid>
		<description>it looks like the compiler version macros did not change with update 1,so I don&#039;t think you&#039;ll have to do any work for Update 1</description>
		<content:encoded><![CDATA[<p>it looks like the compiler version macros did not change with update 1,so I don&#8217;t think you&#8217;ll have to do any work for Update 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Boost.SqlCli: How do you connect to a database? by Coward</title>
		<link>http://wthwdik.wordpress.com/2007/07/02/boostsqlcli-how-do-you-connect-to-a-database/#comment-44</link>
		<dc:creator>Coward</dc:creator>
		<pubDate>Wed, 15 Oct 2008 10:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/2007/07/02/boostsqlcli-how-do-you-connect-to-a-database/#comment-44</guid>
		<description>This is an interesting project, can you please update your code with the latest changes to boost sandbox, much appreciated.</description>
		<content:encoded><![CDATA[<p>This is an interesting project, can you please update your code with the latest changes to boost sandbox, much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Rasputin ha chiuso by k.</title>
		<link>http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-43</link>
		<dc:creator>k.</dc:creator>
		<pubDate>Fri, 03 Oct 2008 23:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://wthwdik.wordpress.com/2007/09/23/rasputin-ha-chiuso/#comment-43</guid>
		<description>era un po&#039; di tempo che non passavo da 5 giornate. quando ho visto l&#039;insegna di benetton illuminata al posto della ormai familiare scritta di rasputin sono rimasto di sasso. 
un altro piccolo pezzo di quella che, per me, è milano se ne è andato via.</description>
		<content:encoded><![CDATA[<p>era un po&#8217; di tempo che non passavo da 5 giornate. quando ho visto l&#8217;insegna di benetton illuminata al posto della ormai familiare scritta di rasputin sono rimasto di sasso.<br />
un altro piccolo pezzo di quella che, per me, è milano se ne è andato via.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
