<?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: Remove duplicate values from a List in F#</title>
	<atom:link href="http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/</link>
	<description>Functional programming on .Net</description>
	<lastBuildDate>Wed, 23 Mar 2011 17:29:06 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: FSharp.it &#187; Another interview question</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-7140</link>
		<dc:creator>FSharp.it &#187; Another interview question</dc:creator>
		<pubDate>Wed, 26 Aug 2009 13:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-7140</guid>
		<description>[...] made of the two lists created. The rest of the job is calling some standard library functions to filter duplicates, sort and count the elements of the [...]</description>
		<content:encoded><![CDATA[<p>[...] made of the two lists created. The rest of the job is calling some standard library functions to filter duplicates, sort and count the elements of the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Harrop</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-6114</link>
		<dc:creator>Jon Harrop</dc:creator>
		<pubDate>Fri, 17 Jul 2009 07:31:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-6114</guid>
		<description>I think anocka&#039;s comment is wrong. Your algorithm is O(n log n) whereas his is O(n^2).

Also, you can write:

    let nub = set &gt;&gt; List.of_seq</description>
		<content:encoded><![CDATA[<p>I think anocka&#8217;s comment is wrong. Your algorithm is O(n log n) whereas his is O(n^2).</p>
<p>Also, you can write:</p>
<p>    let nub = set &gt;&gt; List.of_seq</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-536</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Fri, 18 Jul 2008 06:12:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-536</guid>
		<description>You could make it shorter:

let nub = Set.of_list &gt;&gt; Set.to_list

:)</description>
		<content:encoded><![CDATA[<p>You could make it shorter:</p>
<p>let nub = Set.of_list &gt;&gt; Set.to_list</p>
<p> <img src='http://www.fsharp.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Furrer</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-467</link>
		<dc:creator>Daniel Furrer</dc:creator>
		<pubDate>Mon, 30 Jun 2008 11:40:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-467</guid>
		<description>Leaving performance aside, the version that anocka proposed can be adapted to make sure elements in the list do not change order, which is important in some cases.

Here&#039;s what I am using:

let remove_duplicates list =
    let add_elem acc_list elem =
        if List.mem elem acc_list then
            acc_list
        else
            acc_list @ [elem]
    List.fold_left add_elem [] list</description>
		<content:encoded><![CDATA[<p>Leaving performance aside, the version that anocka proposed can be adapted to make sure elements in the list do not change order, which is important in some cases.</p>
<p>Here&#8217;s what I am using:</p>
<p>let remove_duplicates list =<br />
    let add_elem acc_list elem =<br />
        if List.mem elem acc_list then<br />
            acc_list<br />
        else<br />
            acc_list @ [elem]<br />
    List.fold_left add_elem [] list</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anocka</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-282</link>
		<dc:creator>anocka</dc:creator>
		<pubDate>Sun, 27 Apr 2008 14:04:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-282</guid>
		<description>Well, I did not think it through : you algorithm has a O(n*log(n))  complexity while mine is O(n²)...</description>
		<content:encoded><![CDATA[<p>Well, I did not think it through : you algorithm has a O(n*log(n))  complexity while mine is O(n²)&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anocka</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-281</link>
		<dc:creator>anocka</dc:creator>
		<pubDate>Sun, 27 Apr 2008 13:40:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-281</guid>
		<description>This may seem elegant, but I&#039;m afraid this would be to slow on large lists. Another elegant solution uses the fold operator.
First define a function that adds an element to a list if it does not already belong to it :

let add_elem elem list =
    if List.mem elem list then list else elem :: list

Then you use it to accumulate on the list to build one without duplicate values :
let nub list = List.fold_right add_elem list []

Fold power !
PS : Actually, that&#039;s ocaml code, but I think it should work on F#.</description>
		<content:encoded><![CDATA[<p>This may seem elegant, but I&#8217;m afraid this would be to slow on large lists. Another elegant solution uses the fold operator.<br />
First define a function that adds an element to a list if it does not already belong to it :</p>
<p>let add_elem elem list =<br />
    if List.mem elem list then list else elem :: list</p>
<p>Then you use it to accumulate on the list to build one without duplicate values :<br />
let nub list = List.fold_right add_elem list []</p>
<p>Fold power !<br />
PS : Actually, that&#8217;s ocaml code, but I think it should work on F#.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: claudio</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-279</link>
		<dc:creator>claudio</dc:creator>
		<pubDate>Thu, 24 Apr 2008 20:33:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-279</guid>
		<description>I totally agree with you...</description>
		<content:encoded><![CDATA[<p>I totally agree with you&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akiva</title>
		<link>http://www.fsharp.it/2008/04/23/remove-duplicate-values-from-a-list-in-f/comment-page-1/#comment-278</link>
		<dc:creator>Akiva</dc:creator>
		<pubDate>Thu, 24 Apr 2008 20:29:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=29#comment-278</guid>
		<description>It&#039;s precisely this kind of thing that makes me love F# more and more each day.</description>
		<content:encoded><![CDATA[<p>It&#8217;s precisely this kind of thing that makes me love F# more and more each day.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

