<?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"
	>
<channel>
	<title>Comments on: Playing with Haskell&#8217;s lazy lists</title>
	<atom:link href="http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/</link>
	<description>Just another programming weblog</description>
	<pubDate>Tue, 06 Jan 2009 23:56:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Bookmarks about Dev</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-69</link>
		<dc:creator>Bookmarks about Dev</dc:creator>
		<pubDate>Sun, 17 Aug 2008 17:45:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-69</guid>
		<description>&lt;p&gt;[...] - bookmarked by 4 members originally found by christopherllc on 2008-07-24  Playing with Haskell’s lazy lists  http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/ - bookmarked by 3 members [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] - bookmarked by 4 members originally found by christopherllc on 2008-07-24  Playing with Haskell’s lazy lists  <a href="http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/" rel="nofollow">http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/</a> - bookmarked by 3 members [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: A Better &#8216;nub&#8217; &#8226; OJ&#8217;s rants</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-56</link>
		<dc:creator>A Better &#8216;nub&#8217; &#8226; OJ&#8217;s rants</dc:creator>
		<pubDate>Mon, 28 Jul 2008 10:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-56</guid>
		<description>&lt;p&gt;[...] my TODO list, but I haven&#8217;t yet got round to it. So you can imagine my delight when I found this comment by Jedai over at hvergi.net. He&#8217;d pointed out that nub was indeed inefficient, and showed an [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] my TODO list, but I haven&#8217;t yet got round to it. So you can imagine my delight when I found this comment by Jedai over at hvergi.net. He&#8217;d pointed out that nub was indeed inefficient, and showed an [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-55</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Mon, 28 Jul 2008 01:05:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-55</guid>
		<description>&lt;p&gt;Great tidbit Jedai! I'll be adding that to the memory banks. Might even post about it to share the knowledge. :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Great tidbit Jedai! I&#8217;ll be adding that to the memory banks. Might even post about it to share the knowledge. :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Arnar</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-53</link>
		<dc:creator>Arnar</dc:creator>
		<pubDate>Thu, 24 Jul 2008 18:51:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-53</guid>
		<description>&lt;p&gt;@Jedai: thanks. I wonder why nub isn't implemented like this in the first place, relying on Ord rather than Eq.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Jedai: thanks. I wonder why nub isn&#8217;t implemented like this in the first place, relying on Ord rather than Eq.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jedai</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-50</link>
		<dc:creator>Jedai</dc:creator>
		<pubDate>Thu, 24 Jul 2008 14:57:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-50</guid>
		<description>&lt;p&gt;Note that nub only demands that the list element be part of the Eq typeclass. As a result it is very inefficient and a better solution must always be prefered whenever the nature of the elements allows it.&lt;/p&gt;

&lt;p&gt;&lt;pre lang="haskell"&gt;import qualified Data.Set as S
nub' :: (Ord a) =&gt; [a] -&gt; [a]
nub' = go S.empty
  where go _ [] = []
        go s (x:xs) &#124; S.member x s = go s xs
                    &#124; otherwise    = x : go (S.insert x s) xs
&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;La différence de performance est énorme.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Note that nub only demands that the list element be part of the Eq typeclass. As a result it is very inefficient and a better solution must always be prefered whenever the nature of the elements allows it.</p>

<p>

</p>
<div class="wp_syntax"><div class="code"><pre class="haskell"><span style="color: #06c; font-weight: bold;">import</span> <span style="color: #06c; font-weight: bold;">qualified</span> Data<span style="color: #999;">.</span>Set <span style="color: #06c; font-weight: bold;">as</span> S
nub' <span style="color: #999;">::</span> <span style="color: #777;">&#40;</span><span style="color: #295585;">Ord</span> a<span style="color: #777;">&#41;</span> <span style="color: #999;">=&gt;</span> <span style="color: #777;">&#91;</span>a<span style="color: #777;">&#93;</span> <span style="color: #999;">-&gt;</span> <span style="color: #777;">&#91;</span>a<span style="color: #777;">&#93;</span>
nub' <span style="color: #999;">=</span> go S<span style="color: #999;">.</span>empty
  <span style="color: #06c; font-weight: bold;">where</span> go <span style="color: #999;">_</span> <span style="color: #777;">&#91;</span><span style="color: #777;">&#93;</span> <span style="color: #999;">=</span> <span style="color: #777;">&#91;</span><span style="color: #777;">&#93;</span>
        go s <span style="color: #777;">&#40;</span>x:xs<span style="color: #777;">&#41;</span> <span style="color: #999;">|</span> S<span style="color: #999;">.</span>member x s <span style="color: #999;">=</span> go s xs
                    <span style="color: #999;">|</span> <span style="font-weight: bold;">otherwise</span>    <span style="color: #999;">=</span> x : go <span style="color: #777;">&#40;</span>S<span style="color: #999;">.</span>insert x s<span style="color: #777;">&#41;</span> xs</pre></div></div>




<p>La différence de performance est énorme.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-49</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Thu, 24 Jul 2008 11:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-49</guid>
		<description>&lt;p&gt;I suffer from the same kind of thing myself mate. I'm still relatively new to Haskell, and have a lot to learn. It's a fantastic language though.&lt;/p&gt;

&lt;p&gt;Keep up the great work with the blog, and thanks for offering your advice on my Haskell solutions to Project Euler :) Cheers!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I suffer from the same kind of thing myself mate. I&#8217;m still relatively new to Haskell, and have a lot to learn. It&#8217;s a fantastic language though.</p>

<p>Keep up the great work with the blog, and thanks for offering your advice on my Haskell solutions to Project Euler :) Cheers!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Arnar</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-47</link>
		<dc:creator>Arnar</dc:creator>
		<pubDate>Thu, 24 Jul 2008 10:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-47</guid>
		<description>&lt;p&gt;@OJ: Ah, yes.. I agree, the list comprehension is much more readable. I guess I should have that in mind whenever I find myself writing something with the form &lt;code&gt;map (\x -&#62; term) xs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@OJ: Ah, yes.. I agree, the list comprehension is much more readable. I guess I should have that in mind whenever I find myself writing something with the form <code>map (\x -&gt; term) xs</code>.</p>

<p>Thanks!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/#comment-45</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Thu, 24 Jul 2008 04:26:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.hvergi.net/?p=29#comment-45</guid>
		<description>&lt;p&gt;While this is functionality equiv (I think ... I haven't compiled it :)), I think it's a better option than the version listed above, as I find it easier on the eyes :)&lt;/p&gt;

&lt;p&gt;let a' = (1 ,7) : [ (n + 1, x + (gcd (n + 1) x)) &#124; (n, x) &#60;- a' ]&lt;/p&gt;

&lt;p&gt;Perhaps it's just me, but list comprehensions tend to win the readability award when compared to lambda expressions.&lt;/p&gt;

&lt;p&gt;Nice blog!
Cheers.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>While this is functionality equiv (I think &#8230; I haven&#8217;t compiled it :)), I think it&#8217;s a better option than the version listed above, as I find it easier on the eyes :)</p>

<p>let a&#8217; = (1 ,7) : [ (n + 1, x + (gcd (n + 1) x)) | (n, x) &lt;- a' ]</p>

<p>Perhaps it&#8217;s just me, but list comprehensions tend to win the readability award when compared to lambda expressions.</p>

<p>Nice blog!
Cheers.</p>]]></content:encoded>
	</item>
</channel>
</rss>
