<?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: Haskell Gem: Unwrapping Indented Text</title>
	<atom:link href="http://davidsiegel.org/haskell-unwrap/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidsiegel.org/haskell-unwrap/</link>
	<description>David Siegel</description>
	<lastBuildDate>Thu, 04 Mar 2010 01:16:34 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: David</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1908</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sun, 08 Nov 2009 03:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1908</guid>
		<description>Paul, very cool, thank you for both of your interesting solutions.

Yitz, thanks for the heads up and I like your insane one-liner :) I tried to write something that non-Haskellers could find interesting, but I do think your approach is totally rad.</description>
		<content:encoded><![CDATA[<p>Paul, very cool, thank you for both of your interesting solutions.</p>
<p>Yitz, thanks for the heads up and I like your insane one-liner <img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/smile.png' alt='Smile' title='Smile' class='tse-smiley' /> I tried to write something that non-Haskellers could find interesting, but I do think your approach is totally rad.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yitz</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1906</link>
		<dc:creator>Yitz</dc:creator>
		<pubDate>Sun, 08 Nov 2009 01:30:36 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1906</guid>
		<description>Nice post. It was linked on the Haskell reddit: http://www.reddit.com/r/haskell/comments/a14mv/haskell_gem_unwrapping_indented_text/

More comments there.</description>
		<content:encoded><![CDATA[<p>Nice post. It was linked on the Haskell reddit: <a href="http://www.reddit.com/r/haskell/comments/a14mv/haskell_gem_unwrapping_indented_text/" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/www.reddit.com/r/haskell/comments/a14mv/haskell_gem_unwrapping_indented_text/?referer=');">http://www.reddit.com/r/haskell/comments/a14mv/haskell_gem_unwrapping_indented_text/</a></p>
<p>More comments there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Battley</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1902</link>
		<dc:creator>Paul Battley</dc:creator>
		<pubDate>Thu, 05 Nov 2009 23:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1902</guid>
		<description>There&#039;s a typo in my solution (&quot;&quot; should be &quot; &quot;) but I&#039;m not sure what you mean by &quot;real lines&quot;. If you mean that you want a pure function that maps lines with indented lines to lines with the indented lines concatenated, then you could do this:

http://gist.github.com/227510

But that&#039;s not how I&#039;d implement it in Ruby by choice!</description>
		<content:encoded><![CDATA[<p>There&#8217;s a typo in my solution (&#8220;&#8221; should be &#8221; &#8220<img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' /> but I&#8217;m not sure what you mean by &#8220;real lines&#8221;. If you mean that you want a pure function that maps lines with indented lines to lines with the indented lines concatenated, then you could do this:</p>
<p><a href="http://gist.github.com/227510" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/gist.github.com/227510?referer=');">http://gist.github.com/227510</a></p>
<p>But that&#8217;s not how I&#8217;d implement it in Ruby by choice!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1901</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 05 Nov 2009 22:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1901</guid>
		<description>Paul, I didn&#039;t say it explicitly, but the goal is to create a pure function that unwraps indented lines only, preserving &quot;real lines&quot;.</description>
		<content:encoded><![CDATA[<p>Paul, I didn&#8217;t say it explicitly, but the goal is to create a pure function that unwraps indented lines only, preserving &#8220;real lines&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Battley</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1900</link>
		<dc:creator>Paul Battley</dc:creator>
		<pubDate>Thu, 05 Nov 2009 22:37:06 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1900</guid>
		<description>In Ruby:

$stdout &lt;&lt; $stdin.read.gsub(/\n +/, &quot;&quot;)

It does read the entire file into memory first, though.</description>
		<content:encoded><![CDATA[<p>In Ruby:</p>
<p>$stdout &lt;&lt; $stdin.read.gsub(/\n +/, &quot;&quot<img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' /></p>
<p>It does read the entire file into memory first, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rudolf O.</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1898</link>
		<dc:creator>Rudolf O.</dc:creator>
		<pubDate>Thu, 05 Nov 2009 18:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1898</guid>
		<description>Okay, I think I figured it out: http://neverfriday.com/temp/unwrap/unwrap.html

Also, I didn&#039;t see that it was just one step as part of something more. I&#039;m justifying my choice to make this a small program with the fact that it would be easy to chain things up on a GNU/Linux system ;)

I mean, you *are* using cat, piping ;p</description>
		<content:encoded><![CDATA[<p>Okay, I think I figured it out: <a href="http://neverfriday.com/temp/unwrap/unwrap.html" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/neverfriday.com/temp/unwrap/unwrap.html?referer=');">http://neverfriday.com/temp/unwrap/unwrap.html</a></p>
<p>Also, I didn&#8217;t see that it was just one step as part of something more. I&#8217;m justifying my choice to make this a small program with the fact that it would be easy to chain things up on a GNU/Linux system <img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' /></p>
<p>I mean, you *are* using cat, piping ;p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1896</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 05 Nov 2009 15:31:32 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1896</guid>
		<description>Andre: awesome, that&#039;s exactly what I was looking for to be able to compare solutions.

Igor: Very cool!</description>
		<content:encoded><![CDATA[<p>Andre: awesome, that&#8217;s exactly what I was looking for to be able to compare solutions.</p>
<p>Igor: Very cool!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1895</link>
		<dc:creator>Igor</dc:creator>
		<pubDate>Thu, 05 Nov 2009 15:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1895</guid>
		<description>Ooops, looks like the HTML sanitizer ate my characters :) So, the part that looks like @in = ; should look like @in = &lt;&gt;;</description>
		<content:encoded><![CDATA[<p>Ooops, looks like the HTML sanitizer ate my characters <img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/smile.png' alt='Smile' title='Smile' class='tse-smiley' /> So, the part that looks like @in = ; should look like @in = &lt;&gt;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1894</link>
		<dc:creator>Igor</dc:creator>
		<pubDate>Thu, 05 Nov 2009 15:08:53 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1894</guid>
		<description>There&#039;s a Perl one-liner for ya:

perl -e &#039;sub unwrap {$one = join(&quot;&quot;, @_); $one =~ s/\n\s+//g; split(&quot;\n&quot;,$one)} @in = ; print join(&quot;\n&quot;,unwrap(@in)),&quot;\n&quot;;&#039;  &lt; header

The basic logic is the same as the Haskell original, but I used a regular expression for the unwrapping part. The unwrap function in there receives a list of strings and returns a list of &quot;unwrapped&quot; strings.

I admit, this &quot;line&quot; is a bit long, but... :)</description>
		<content:encoded><![CDATA[<p>There&#8217;s a Perl one-liner for ya:</p>
<p>perl -e &#8217;sub unwrap {$one = join(&#8220;&#8221;, @_); $one =~ s/\n\s+//g; split(&#8220;\n&#8221;,$one)} @in = ; print join(&#8220;\n&#8221;,unwrap(@in)),&#8221;\n&#8221;;&#8217;  &lt; header</p>
<p>The basic logic is the same as the Haskell original, but I used a regular expression for the unwrapping part. The unwrap function in there receives a list of strings and returns a list of &quot;unwrapped&quot; strings.</p>
<p>I admit, this &quot;line&quot; is a bit long, but&#8230; <img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/smile.png' alt='Smile' title='Smile' class='tse-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://davidsiegel.org/haskell-unwrap/comment-page-1/#comment-1893</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 05 Nov 2009 14:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://davidsiegel.org/?p=566#comment-1893</guid>
		<description>If you insist that unwrap be a function of a list of strings returning a unwrapped list of strings, an impure Lua solution would be:

function unwrap(lines)
  local result = {}
  for _, line in ipairs(lines) do
    if string.match(line, &quot;^%s&quot;) then
      result[#result] = (result[#result] or &quot;&quot;) .. (string.gsub(line, &quot;^%s+&quot;, &quot; &quot;))
    else
      table.insert(result, line)
    end
  end
  return result
end</description>
		<content:encoded><![CDATA[<p>If you insist that unwrap be a function of a list of strings returning a unwrapped list of strings, an impure Lua solution would be:</p>
<p>function unwrap(lines)<br />
  local result = {}<br />
  for _, line in ipairs(lines) do<br />
    if string.match(line, &#8220;^%s&#8221<img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' /> then<br />
      result[#result] = (result[#result] or &#8220;&#8221<img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' /> .. (string.gsub(line, &#8220;^%s+&#8221;, &#8221; &#8220<img src='http://davidsiegel.org/wp-content/plugins/tango-smileys-extended/tango/wink.png' alt='Wink' title='Wink' class='tse-smiley' />)<br />
    else<br />
      table.insert(result, line)<br />
    end<br />
  end<br />
  return result<br />
end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
