<?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>A Tempest of Thoughts &#187; Learning Erlang</title>
	<atom:link href="http://tempe.st/category/learning-erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 07 Apr 2011 08:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Learning Erlang: The Beautiful Quicksort</title>
		<link>http://tempe.st/2007/04/learning-erlang-the-beautiful-quicksort/</link>
		<comments>http://tempe.st/2007/04/learning-erlang-the-beautiful-quicksort/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 11:02:42 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Learning Erlang]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/04/learning-erlang-the-beautiful-quicksort/</guid>
		<description><![CDATA[Sometimes you really have to stop and contemplate how beautiful code is. This is an erlang quicksort algorithm, one of the most efficient (if I remember correctly it&#8217;s the most efficient) sorting algorithms. I still remember the pains of implementing it in C. qsort&#40;&#91;&#93;&#41; -&#62; &#91;&#93;; qsort&#40;&#91;Pivot&#124;T&#93;&#41; -&#62; qsort&#40;&#91;X &#124;&#124; X &#60;- T, X =&#60; [...]]]></description>
			<content:encoded><![CDATA[	<p>Sometimes you really have to stop and contemplate how beautiful code is. This is an erlang quicksort algorithm, one of the most efficient (if I remember correctly it&#8217;s the most efficient) sorting algorithms. I still remember the pains of implementing it in C.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff3c00;">qsort</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">;</span>
<span style="color: #ff3c00;">qsort</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Pivot</span>|T<span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
	<span style="color: #ff3c00;">qsort</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">||</span> <span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #45b3e6;">T</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">=&lt;</span> <span style="color: #45b3e6;">Pivot</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span>
	<span style="color: #014ea4;">++</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Pivot</span><span style="color: #109ab8;">&#93;</span> <span style="color: #014ea4;">++</span>
	<span style="color: #ff3c00;">qsort</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">||</span> <span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #45b3e6;">T</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">X</span> <span style="color: #014ea4;">&gt;</span> <span style="color: #45b3e6;">Pivot</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

	<p>Short + Clean + Elegant = Beautiful.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/04/learning-erlang-the-beautiful-quicksort/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Learning Erlang, day 1: No Variables?</title>
		<link>http://tempe.st/2007/03/learning-erlang-day-1-no-variables/</link>
		<comments>http://tempe.st/2007/03/learning-erlang-day-1-no-variables/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 09:13:23 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Learning Erlang]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/03/learning-erlang-day-1-no-variables/</guid>
		<description><![CDATA[I first heard of Erlang from SamePlace creator, Massimiliano Mirra. He mostly praised the functional nature of the language and its performance. I always listen to my friends, so I made a mental note, and every once in a while I tried to start with Erlang, but other stuff(tm) always got the priority. A few [...]]]></description>
			<content:encoded><![CDATA[	<p>I first heard of Erlang from <a href="http://sameplace.cc">SamePlace</a> creator, Massimiliano Mirra. He mostly praised the functional nature of the language and its performance.</p>
	<p>I always listen to my friends, so I made a mental note, and every once in a while I tried to start with Erlang, but <em>other stuff</em>(tm) always got the priority.</p>
	<p>A few days ago, generating a burst of blog posts, the <a href="http://pragmaticprogrammer.com">Pragmatic Programmers</a>  released  the beta version of  <a href="http://www.pragmaticprogrammer.com/titles/jaerlang/">Programming Erlang</a>. This was not a coincidence. When both Massimiliano and the Pragmatic Programmers suggest you should learn a new language you better do it, and be happy <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>So I went to the pragprog website and looked through the table of contents. It was really interesting and I bought the beta book.</p>
	<p>Yesterday I got my hands wet with erlangness for the first time and decided to create a new category of posts, <a href="http://tempe.st/category/learning-erlang">Learning Erlang</a>, that will be filled with my observation about my efforts to learn a functional language after all these years of object orientedness.</p>
	<p>The first thing you will notice when working with erlang is that there are <strong>no variables</strong>. Ok, stop, don&#8217;t close the browser, it&#8217;s not entirely true, there are variables, but you can assign them only once. </p>
	<p>To better explain how erlang treats variables I&#8217;ll show you a snippet taken from the erlang interactive interpreter, <em>erl</em>:</p>
<pre>
Eshell V5.5.3  (abort with ^G)
1&gt; X = 45.
45
2&gt; X.
45
3&gt; X = 23.
	<p>=ERROR REPORT==== 15-Mar-2007::09:55:53 ===<br />
Error in process &lt;0.29.0&gt; with exit value: {{badmatch,23},[{erl_eval,expr,3}]}</p>
	<ul>
		<li>exited: {{badmatch,23},[{erl_eval,expr,3}]} **
4&gt; X = 45.
45
</pre>
	<p>Line 1 just assigns the <em>X</em> variable (in erlang variables start with a capital letter, and statements end with a period). What erlang really does here is matching <em>X</em> with 45. It notices that <em>X</em> is unbound and does whatever it can to make the statement true, so it binds <em>X</em> to 45. In line 2 we just check what <em>X</em> is bound to. In line 3 we learn how erlang works by trying to match <em>X</em> (now 45) to 23. <strong>Boom!</strong> nasty error for us. Being very scared, in line 4 we try to match <em>X</em> to 45, just in case, and we notice erlang likes that statement.</p>
	<p>I promise that once you get used to this way of handling variables it doesn&#8217;t look so strange anymore <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/03/learning-erlang-day-1-no-variables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

