<?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/"
		>
<channel>
	<title>Comments on: Meeting 21 &#8211; Programming Erlang</title>
	<atom:link href="http://www.oxtremists.co.uk/?feed=rss2&#038;p=68" rel="self" type="application/rss+xml" />
	<link>http://www.oxtremists.co.uk/?p=68</link>
	<description>Oxford-based tech discussion group.</description>
	<lastBuildDate>Thu, 05 Nov 2009 22:22:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: chris</title>
		<link>http://www.oxtremists.co.uk/?p=68&#038;cpage=1#comment-8115</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Tue, 15 Jan 2008 10:13:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.oxtremists.co.uk/?p=68#comment-8115</guid>
		<description><![CDATA[Thanks for writing up some notes Tom!  It seems like I&#039;m the only person who has been doing any programming in Erlang.  In fact I&#039;ve made a point of doing what Tom mentioned, which is to actually try out some examples as I&#039;ve gone through.

I agree with much of what was said.  I&#039;m completely new to functional programming so it has been interesting to look at coding from this novel angle.  I&#039;ve found it a little hard at times to shake off my imperative coding habits.

So I have followed the examples and tried the exercises.  One piece of code that just looked wrong to me was the find_sync routine on p85.  This looks for three consecutive MPEG headers in the data.  The issue I had with this is that it is basically the same piece of code embedded within itself three times.  Not what I would call elegant!  I was forced to rewrite this just for my own piece of mind.  I added it to the example code and called it find_sync2.  You can find it here:
http://oxtremists.co.uk/svn/erlang/mp3_sync.erl
any comments on this code would be readily accepted.  I did test it on a real mp3 file and it seemed to do the same as the original.

Something else I started was a sudoku solver program.  The main problem I hit with this was in deciding how I should store the data representing a grid.  Initially I started out with a list, as that seems to be the standard collection type in use in Erlang.  But lists are not really random-access collections.  There is no BIF to allow you to replace the Nth item with M for example.  I also started noticing that the list processing BIFs that there are seem to be rather inconsistent.  So lists:sublist which gives you the first N items in a list takes the argument list (List, N) but lists:nthtail which does the reverse and gives you the items following the first N items takes the argument list (N, List).  

So how about tuples?  There&#039;s a BIF to replace the Nth element with a different one, but there are very few other BIFs available to do anything else.  Finally I found that there is an array module (not mentioned in the book) http://erlang.org/doc/man/array.html should I be using that?  Basically, I&#039;m confused.  Obviously I could do it using any of these, but I don&#039;t want to go re-inventing any wheels on the way....]]></description>
		<content:encoded><![CDATA[<p>Thanks for writing up some notes Tom!  It seems like I&#8217;m the only person who has been doing any programming in Erlang.  In fact I&#8217;ve made a point of doing what Tom mentioned, which is to actually try out some examples as I&#8217;ve gone through.</p>
<p>I agree with much of what was said.  I&#8217;m completely new to functional programming so it has been interesting to look at coding from this novel angle.  I&#8217;ve found it a little hard at times to shake off my imperative coding habits.</p>
<p>So I have followed the examples and tried the exercises.  One piece of code that just looked wrong to me was the find_sync routine on p85.  This looks for three consecutive MPEG headers in the data.  The issue I had with this is that it is basically the same piece of code embedded within itself three times.  Not what I would call elegant!  I was forced to rewrite this just for my own piece of mind.  I added it to the example code and called it find_sync2.  You can find it here:<br />
<a href="http://oxtremists.co.uk/svn/erlang/mp3_sync.erl" rel="nofollow">http://oxtremists.co.uk/svn/erlang/mp3_sync.erl</a><br />
any comments on this code would be readily accepted.  I did test it on a real mp3 file and it seemed to do the same as the original.</p>
<p>Something else I started was a sudoku solver program.  The main problem I hit with this was in deciding how I should store the data representing a grid.  Initially I started out with a list, as that seems to be the standard collection type in use in Erlang.  But lists are not really random-access collections.  There is no BIF to allow you to replace the Nth item with M for example.  I also started noticing that the list processing BIFs that there are seem to be rather inconsistent.  So lists:sublist which gives you the first N items in a list takes the argument list (List, N) but lists:nthtail which does the reverse and gives you the items following the first N items takes the argument list (N, List).  </p>
<p>So how about tuples?  There&#8217;s a BIF to replace the Nth element with a different one, but there are very few other BIFs available to do anything else.  Finally I found that there is an array module (not mentioned in the book) <a href="http://erlang.org/doc/man/array.html" rel="nofollow">http://erlang.org/doc/man/array.html</a> should I be using that?  Basically, I&#8217;m confused.  Obviously I could do it using any of these, but I don&#8217;t want to go re-inventing any wheels on the way&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
