<?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: Run-Length Encoding in F#</title>
	<atom:link href="http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=run-length-encoding-in-f</link>
	<description>Life of a Googler</description>
	<lastBuildDate>Sat, 04 Sep 2010 11:07:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Decoding RLE in F# &#187; FSharp.it</title>
		<link>http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/comment-page-1/#comment-20423</link>
		<dc:creator>Decoding RLE in F# &#187; FSharp.it</dc:creator>
		<pubDate>Tue, 11 Mar 2008 11:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/#comment-20423</guid>
		<description>[...] A couple of days ago, we saw how to implement the Run-Length Encoding (RLE) algorithm to encode an array of elements and now we are going to describe how to restore the original array. [...]</description>
		<content:encoded><![CDATA[<p>[...] A couple of days ago, we saw how to implement the Run-Length Encoding (RLE) algorithm to encode an array of elements and now we are going to describe how to restore the original array. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michiel Borkent</title>
		<link>http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/comment-page-1/#comment-20424</link>
		<dc:creator>Michiel Borkent</dc:creator>
		<pubDate>Sat, 08 Mar 2008 11:41:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.claudiocherubino.it/2008/03/07/run-length-encoding-in-f/#comment-20424</guid>
		<description>Here is my version of run which builds the encoding directly during the recursion:

[fsharp]
#light

let source = [&#039;a&#039;; &#039;a&#039;; &#039;a&#039;; &#039;a&#039;; &#039;b&#039;; &#039;c&#039;; &#039;c&#039;; &#039;a&#039;; &#039;a&#039;; &#039;d&#039;; &#039;e&#039;; &#039;e&#039;; &#039;e&#039;; &#039;e&#039;]

let encode list =
    let rec altpack list pack =
        match (list,pack) with
        &#124; ([],_) -&gt; (list,List.rev pack)
        &#124; (hl::tl,[]) -&gt; altpack tl [(1,hl)]
        &#124; (hl::tl,(x,y)::tp) -&gt; if y=hl then altpack tl ((x+1,y)::tp)
                                              else altpack tl ((1,hl)::pack)
    snd (altpack list [])

let answer = encode source
[/fsharp]</description>
		<content:encoded><![CDATA[<p>Here is my version of run which builds the encoding directly during the recursion:</p>
<pre class="brush: fsharp;">
#light

let source = ['a'; 'a'; 'a'; 'a'; 'b'; 'c'; 'c'; 'a'; 'a'; 'd'; 'e'; 'e'; 'e'; 'e']

let encode list =
    let rec altpack list pack =
        match (list,pack) with
        | ([],_) -&gt; (list,List.rev pack)
        | (hl::tl,[]) -&gt; altpack tl [(1,hl)]
        | (hl::tl,(x,y)::tp) -&gt; if y=hl then altpack tl ((x+1,y)::tp)
                                              else altpack tl ((1,hl)::pack)
    snd (altpack list [])

let answer = encode source
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
