<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://united-coders.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>united-coders.com - programming</title>
 <link>http://united-coders.com/taxonomy/term/20/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>Functional programming with Python</title>
 <link>http://united-coders.com/christian-harms/functional-programming-with-python</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;To work with lists many c/c++ programmer use a simple for-loop. I will try to explain how this can be made a little bit easier. For that I use the self-explaining script language python.&lt;/p&gt;
&lt;p&gt;Here is a simple example to filter all odd integers from a list in simple &lt;b&gt;python 2.x&lt;/b&gt; syntax.&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;python geshifilter-python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; filter_odd&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;myList&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;: &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;result = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# initialize the result list &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; num &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; myList: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# iterate over the list &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; num &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt; == &lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# modulo 2 return 1 for odd integers&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; result.&lt;span style=&quot;color: black;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;num&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# add to the result&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;return&lt;/span&gt; result &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/functional-programming-with-python&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/functional-programming-with-python&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/functional-programming-with-python&quot; dc:title=&quot;Functional programming with Python&quot; trackback:ping=&quot;http://united-coders.com/trackback/11&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-4127&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/functional-programming-with-python#comments</comments>
 <category domain="http://united-coders.com/category/tags/filter">filter</category>
 <category domain="http://united-coders.com/category/tags/functional">functional</category>
 <category domain="http://united-coders.com/category/tags/list-comprehension">list comprehension</category>
 <category domain="http://united-coders.com/category/tags/map">map</category>
 <category domain="http://united-coders.com/category/tags/programming">programming</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/reduce">reduce</category>
 <pubDate>Mon, 30 Mar 2009 20:28:05 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">11 at http://united-coders.com</guid>
</item>
</channel>
</rss>


