<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Tag accumulate</title>
    <link>http://blog.objectmentor.com/articles/tag/accumulate</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>A Few C plus plus TDD videos</title>
      <description>&lt;p&gt;Using CppUTest, gcc 4.4 and the Eclipse &lt;span class="caps"&gt;CDT&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;Rough, as usual.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.vimeo.com/album/254486"&gt;The Video Album&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Might redo first one with increased font size. Considering redoing whole series at 800&amp;#215;600.&lt;/p&gt;</description>
      <pubDate>Mon, 12 Jul 2010 06:30:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a05f9c5f-4b90-46ab-9eaf-72750d3ae303</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2010/07/12/a-few-c-plus-plus-tdd-videos</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>c</category>
      <category>plus</category>
      <category>std</category>
      <category>tr1</category>
      <category>accumulate</category>
      <category>for_each</category>
      <category>bind</category>
      <category>_1</category>
      <category>refactoring</category>
      <category>array</category>
      <category>vector</category>
      <category>random</category>
    </item>
    <item>
      <title>C++ Algorithms, Boost and function currying</title>
      <description>&lt;p&gt;I&amp;#8217;ve been experimenting with C++ using the Eclipse &lt;span class="caps"&gt;CDT&lt;/span&gt; and gcc 4.4. Since I&amp;#8217;m a fan of boost, I&amp;#8217;ve been using that as well. I finally got into I realistic use of boost::bind.&lt;/p&gt;


I converted this:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;int Dice::total() const {
  int total = 0;

  for(const_iterator current = dice.begin();
      current != dice.end();
      ++current)
    total += (*current)-&amp;gt;faceValue();

  return total;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Into this:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;int Dice::total() const {
  return std::accumulate(
      dice.begin(),
      dice.end(),
      0,
      bind(std::plus&amp;lt;int&amp;gt;(), _1, bind(&amp;amp;Die::faceValue, _2))
  );
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;To see how to go from the first version to the final version with lots of steps in between: &lt;a href="http://schuchert.wikispaces.com/cpptraining.SummingAVector"&gt;http://schuchert.wikispaces.com/cpptraining.SummingAVector&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This is a first draft. I&amp;#8217;ll be cleaning it up over the next few days. If you see typos, or if anything is not clear from the code, please let me know where. Also, if my interpretation of what boost is doing under the covers (there&amp;#8217;s not much of that) is wrong, please correct me.&lt;/p&gt;


	&lt;p&gt;Thanks!&lt;/p&gt;</description>
      <pubDate>Sat, 12 Jun 2010 23:41:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:549aae6e-42fc-4ae7-ad78-126667918e8d</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2010/06/12/c-algorithms-boost-and-function-currying</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>c</category>
      <category>cpp</category>
      <category>boost</category>
      <category>function</category>
      <category>currying</category>
      <category>std</category>
      <category>for_each</category>
      <category>vector</category>
      <category>shared_ptr</category>
      <category>accumulate</category>
    </item>
  </channel>
</rss>

