<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebFramp &#187; programming</title>
	<atom:link href="http://www.webframp.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webframp.com</link>
	<description>passing thoughts on the web</description>
	<lastBuildDate>Thu, 17 Sep 2009 19:34:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Why Haskell is a joy to learn</title>
		<link>http://www.webframp.com/2009/04/15/why-haskell-is-a-joy-to-learn/</link>
		<comments>http://www.webframp.com/2009/04/15/why-haskell-is-a-joy-to-learn/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 02:04:32 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[musings]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.webframp.com/?p=119</guid>
		<description><![CDATA[I recently discovered Project Euler, an excellent resource to use while learning a new language. Maybe a little late to the game, but fun nonetheless. The very first problem is rather simple: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered <a href="http://projecteuler.net/">Project Euler</a>, an excellent resource to use while learning a new language. Maybe a little late to the game, but fun nonetheless.</p>
<p>The very first <a href="http://projecteuler.net/index.php?section=problems&#038;id=1">problem</a> is rather simple:</p>
<blockquote><p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p>
<p>Find the sum of all the multiples of 3 or 5 below 1000.</p></blockquote>
<p>And a potential solution is haskell is could be to define the following:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">isMultOf x n <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">mod</span> n x <span style="color: #339933; font-weight: bold;">==</span> <span style="color: red;">0</span>
&nbsp;
sumList xs <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">foldr</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">+</span><span style="color: green;">&#41;</span> <span style="color: red;">0</span> xs</pre></div></div>

<p>After which the answer could be obtained with a simple:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">sumList <span style="color: green;">&#91;</span>a <span style="color: #339933; font-weight: bold;">|</span> a <span style="color: #339933; font-weight: bold;">&lt;-</span> <span style="color: green;">&#91;</span>1<span style="color: #339933; font-weight: bold;">..</span>1000<span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> isMultOf <span style="color: red;">3</span> a <span style="color: #339933; font-weight: bold;">||</span> 
                             isMultOf <span style="color: red;">5</span> a<span style="color: #339933; font-weight: bold;">,</span> 
                             a <span style="color: #339933; font-weight: bold;">&lt;</span> <span style="color: red;">1000</span><span style="color: green;">&#93;</span></pre></div></div>

<p>And we have a list comprehension. Beautiful, and immediately expressive of exactly what&#8217;s happening for such a simple problem. The amazing thing is that properly written haskell maintains this same clarity and expressivity in even large scale programs. Sometimes it&#8217;s the little things in a language that makes you really appreciate it.</p>
<p>Hopefully wordpress hasn&#8217;t screwed up the formatting for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webframp.com/2009/04/15/why-haskell-is-a-joy-to-learn/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
