<?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: Small programming challenge</title>
	<atom:link href="http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/</link>
	<description>interested in being interested</description>
	<lastBuildDate>Mon, 05 Apr 2010 15:46:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Frank Shearar</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-146</link>
		<dc:creator>Frank Shearar</dc:creator>
		<pubDate>Mon, 21 Sep 2009 10:54:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-146</guid>
		<description>Hey Andreas,

Ja, REST is CDR, basically (and FIRST is CAR). The Common Lisp HyperSpec says &quot;rest is often preferred stylistically over cdr when the argument is to being subjectively viewed as a list rather than as a cons.&quot;

The similarities between Prolog and Erlang are to be expected, of course, given Erlang&#039;s history as starting out as a hacked up concurrent Prolog.

It&#039;s the lack of the notion of a function that returns something that makes my implementation look so yuck. It&#039;s pretty much a straight-up translation of the Erlang version.

And Danie, kudos for the clever insight! I spent too long thinking how to do the obvious and tedious iterate-over-list way of summing before realising how your Haskell implementation worked.</description>
		<content:encoded><![CDATA[<p>Hey Andreas,</p>
<p>Ja, REST is CDR, basically (and FIRST is CAR). The Common Lisp HyperSpec says &#8220;rest is often preferred stylistically over cdr when the argument is to being subjectively viewed as a list rather than as a cons.&#8221;</p>
<p>The similarities between Prolog and Erlang are to be expected, of course, given Erlang&#8217;s history as starting out as a hacked up concurrent Prolog.</p>
<p>It&#8217;s the lack of the notion of a function that returns something that makes my implementation look so yuck. It&#8217;s pretty much a straight-up translation of the Erlang version.</p>
<p>And Danie, kudos for the clever insight! I spent too long thinking how to do the obvious and tedious iterate-over-list way of summing before realising how your Haskell implementation worked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Pauley</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-145</link>
		<dc:creator>Andreas Pauley</dc:creator>
		<pubDate>Sun, 20 Sep 2009 19:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-145</guid>
		<description>Frank,

Thanks for the Prolog, interesting to see the similarities with Erlang.

My Lisp attempt used cdr where your&#039;s used rest (like Clojure). Cool, I thought Common Lisp was stuck with the cryptic cdr.</description>
		<content:encoded><![CDATA[<p>Frank,</p>
<p>Thanks for the Prolog, interesting to see the similarities with Erlang.</p>
<p>My Lisp attempt used cdr where your&#8217;s used rest (like Clojure). Cool, I thought Common Lisp was stuck with the cryptic cdr.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Shearar</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-144</link>
		<dc:creator>Frank Shearar</dc:creator>
		<pubDate>Sat, 19 Sep 2009 18:38:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-144</guid>
		<description>In Common Lisp:

(defun pairwise-add (l)
  (mapcar #&#039;+ l (rest l)))

I had tried to solve the problem with a fold, before I realised (upon googling zipWith) that I was using the wrong hammer!

Also, please someone improve this Prolog version:

sumpairs([X,Y&#124;T],Out) :- Z is X + Y, sumpairs([Y&#124;T], Tail), append([Z],Tail,Out).
sumpairs(_,[]).

(Yes, I did rampantly steal Danie&#039;s very clever solutions.)</description>
		<content:encoded><![CDATA[<p>In Common Lisp:</p>
<p>(defun pairwise-add (l)<br />
  (mapcar #&#8217;+ l (rest l)))</p>
<p>I had tried to solve the problem with a fold, before I realised (upon googling zipWith) that I was using the wrong hammer!</p>
<p>Also, please someone improve this Prolog version:</p>
<p>sumpairs([X,Y|T],Out) :- Z is X + Y, sumpairs([Y|T], Tail), append([Z],Tail,Out).<br />
sumpairs(_,[]).</p>
<p>(Yes, I did rampantly steal Danie&#8217;s very clever solutions.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Pauley</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-143</link>
		<dc:creator>Andreas Pauley</dc:creator>
		<pubDate>Sat, 19 Sep 2009 11:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-143</guid>
		<description>Danie,

I like the Haskell solution!
It is just as elegant as the Clojure example, and probably much faster.</description>
		<content:encoded><![CDATA[<p>Danie,</p>
<p>I like the Haskell solution!<br />
It is just as elegant as the Clojure example, and probably much faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Pauley</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-142</link>
		<dc:creator>Andreas Pauley</dc:creator>
		<pubDate>Sat, 19 Sep 2009 11:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-142</guid>
		<description>Gabriel,

The Perl solution above returns [3, 7, 11, 15, 9] when I execute it.

According to my calculations it should rather return
[3, 5, 7, 9, 11, 13, 15, 17]

(on an array from 1 to 9)</description>
		<content:encoded><![CDATA[<p>Gabriel,</p>
<p>The Perl solution above returns [3, 7, 11, 15, 9] when I execute it.</p>
<p>According to my calculations it should rather return<br />
[3, 5, 7, 9, 11, 13, 15, 17]</p>
<p>(on an array from 1 to 9)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: danieroux</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-141</link>
		<dc:creator>danieroux</dc:creator>
		<pubDate>Fri, 18 Sep 2009 12:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-141</guid>
		<description>I will be suitably impressed if Scala will be even simpler and shorter than the Haskell version! Beating this for expressibility will be admirable:

zipWith (+) x (tail x)</description>
		<content:encoded><![CDATA[<p>I will be suitably impressed if Scala will be even simpler and shorter than the Haskell version! Beating this for expressibility will be admirable:</p>
<p>zipWith (+) x (tail x)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Fortuna</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-140</link>
		<dc:creator>Gabriel Fortuna</dc:creator>
		<pubDate>Fri, 18 Sep 2009 12:52:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-140</guid>
		<description>Oh wait... it&#039;s 3 lines if you don&#039;t count the array assignment. I could probably make it more concise at the expense of readability, but I strongly dislike Perl Golf (http://en.wikipedia.org/wiki/Perl_golf#Perl_golf)</description>
		<content:encoded><![CDATA[<p>Oh wait&#8230; it&#8217;s 3 lines if you don&#8217;t count the array assignment. I could probably make it more concise at the expense of readability, but I strongly dislike Perl Golf (<a href="http://en.wikipedia.org/wiki/Perl_golf#Perl_golf" rel="nofollow">http://en.wikipedia.org/wiki/Perl_golf#Perl_golf</a>)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Fortuna</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-139</link>
		<dc:creator>Gabriel Fortuna</dc:creator>
		<pubDate>Fri, 18 Sep 2009 12:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-139</guid>
		<description>I did mine in perl in 4 lines... woulda made it 3, but I added a check to modify the array with a 0 as the last element if it&#039;s an odd number of elements. Thanks for the fun exercise. :)

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9);
push @array, 0 if scalar @array % 2;
my %hash  = @array;
my @sum   = map { $hash{$_}+$_ } sort keys %hash;

print Dumper(\@sum);</description>
		<content:encoded><![CDATA[<p>I did mine in perl in 4 lines&#8230; woulda made it 3, but I added a check to modify the array with a 0 as the last element if it&#8217;s an odd number of elements. Thanks for the fun exercise. <img src='http://blog.danieroux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>#!/usr/bin/perl</p>
<p>use strict;<br />
use warnings;<br />
use Data::Dumper;</p>
<p>my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9);<br />
push @array, 0 if scalar @array % 2;<br />
my %hash  = @array;<br />
my @sum   = map { $hash{$_}+$_ } sort keys %hash;</p>
<p>print Dumper(\@sum);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leon Messerschmdit</title>
		<link>http://blog.danieroux.com/2009/09/18/small-programming-challenge-haskell-and-erlang/comment-page-1/#comment-138</link>
		<dc:creator>Leon Messerschmdit</dc:creator>
		<pubDate>Fri, 18 Sep 2009 08:12:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.danieroux.com/?p=59#comment-138</guid>
		<description>Try Scala.  Your example will be simpler and shorter.  Still learning Scala, so I can&#039;t give you an example from the top of my head ;-)</description>
		<content:encoded><![CDATA[<p>Try Scala.  Your example will be simpler and shorter.  Still learning Scala, so I can&#8217;t give you an example from the top of my head <img src='http://blog.danieroux.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

