<?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: F#: Convert sequence to comma separated string</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Thu, 18 Mar 2010 23:35:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jonathan Graehl</title>
		<link>http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/comment-page-1/#comment-20773</link>
		<dc:creator>Jonathan Graehl</dc:creator>
		<pubDate>Sat, 01 Aug 2009 05:22:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1435#comment-20773</guid>
		<description>&lt;pre&gt;let reduceDefault f z s =
    if Seq.isEmpty s then z
    else Seq.reduce f s
let ConvertToCommaSeparatedString s = reduceDefault (fun x y -&gt; x+&quot;,&quot;+y) &quot;&quot; s
&lt;/pre&gt;

roger, nice trick - but it&#039;s wrong if your sequence starts with at least one empty string.</description>
		<content:encoded><![CDATA[<pre>let reduceDefault f z s =
    if Seq.isEmpty s then z
    else Seq.reduce f s
let ConvertToCommaSeparatedString s = reduceDefault (fun x y -&gt; x+","+y) "" s
</pre>
<p>roger, nice trick &#8211; but it's wrong if your sequence starts with at least one empty string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: _St</title>
		<link>http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/comment-page-1/#comment-20728</link>
		<dc:creator>_St</dc:creator>
		<pubDate>Fri, 31 Jul 2009 08:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1435#comment-20728</guid>
		<description>Hello,

I believe that &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/57a79xd0.aspx&quot; rel=&quot;nofollow&quot;&gt;String.Join Method&lt;/a&gt; could the job, too.</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I believe that <a href="http://msdn.microsoft.com/en-us/library/57a79xd0.aspx" rel="nofollow">String.Join Method</a> could the job, too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlo</title>
		<link>http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/comment-page-1/#comment-19909</link>
		<dc:creator>Carlo</dc:creator>
		<pubDate>Fri, 10 Jul 2009 08:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1435#comment-19909</guid>
		<description>Dolphin Smalltalk does it like this which I thought was quite clever. I know this is not a functional style.

do: operation separatedBy: separator 
	&quot;Evaluate the  argument, operation, for each of the 
	receiver&#039;s elements, interspersed with evaluations of the 
	argument, separator. The separator is first evaluated after the first
	element, and is not evaluated after the last element (i.e. it is not evaluated
	at all if there are less than two elements).&quot;

	&#124; sep &#124;
	sep := [sep := separator].	&quot;Switch to the real separator after first eval.&quot;
	self do: 
			[:each &#124; 
			sep value.
			operation value: each]

Squeak and most other Smalltalks do something like the following:

do: elementBlock separatedBy: separatorBlock
	&quot;Evaluate the elementBlock for all elements in the receiver,
	and evaluate the separatorBlock between.&quot;

	&#124; beforeFirst &#124; 
	beforeFirst := true.
	self do:
		[:each &#124;
		beforeFirst
			ifTrue: [beforeFirst := false]
			ifFalse: [separatorBlock value].
		elementBlock value: each]</description>
		<content:encoded><![CDATA[<p>Dolphin Smalltalk does it like this which I thought was quite clever. I know this is not a functional style.</p>
<p>do: operation separatedBy: separator<br />
	"Evaluate the  argument, operation, for each of the<br />
	receiver's elements, interspersed with evaluations of the<br />
	argument, separator. The separator is first evaluated after the first<br />
	element, and is not evaluated after the last element (i.e. it is not evaluated<br />
	at all if there are less than two elements)."</p>
<p>	| sep |<br />
	sep := [sep := separator].	"Switch to the real separator after first eval."<br />
	self do:<br />
			[:each |<br />
			sep value.<br />
			operation value: each]</p>
<p>Squeak and most other Smalltalks do something like the following:</p>
<p>do: elementBlock separatedBy: separatorBlock<br />
	"Evaluate the elementBlock for all elements in the receiver,<br />
	and evaluate the separatorBlock between."</p>
<p>	| beforeFirst |<br />
	beforeFirst := true.<br />
	self do:<br />
		[:each |<br />
		beforeFirst<br />
			ifTrue: [beforeFirst := false]<br />
			ifFalse: [separatorBlock value].<br />
		elementBlock value: each]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roger</title>
		<link>http://www.markhneedham.com/blog/2009/07/09/f-convert-sequence-to-comma-separated-string/comment-page-1/#comment-19860</link>
		<dc:creator>roger</dc:creator>
		<pubDate>Thu, 09 Jul 2009 13:52:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1435#comment-19860</guid>
		<description>I like your last solution, but you could also check if the current state of acc and conditionally add the comma &#039;in front&#039; with the 2nd entry.  fun acc x -&gt; (if acc  &quot;&quot; then &quot;,&quot; else &quot;&quot;) +  x...if&#039;s are expressions.</description>
		<content:encoded><![CDATA[<p>I like your last solution, but you could also check if the current state of acc and conditionally add the comma 'in front' with the 2nd entry.  fun acc x -&gt; (if acc  "" then "," else "") +  x&#8230;if's are expressions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
