<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Grep</title>
	<atom:link href="http://programmingpraxis.com/2009/09/25/grep/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/09/25/grep/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2009/09/25/grep/#comment-644</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Fri, 25 Sep 2009 16:51:19 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1363#comment-644</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2009/09/25/programming-praxis-grep/ for a version with comments):

[sourcecode lang=&quot;css&quot;]
import System.Environment
import Text.Printf

--Code from the previous two exercises goes here

grepString :: Bool -&gt; Maybe String -&gt; [Chunk] -&gt; String -&gt; IO ()
grepString b p cs = mapM_ (printf &quot;%s%s\n&quot; $ maybe &quot;&quot; (++ &quot;: &quot;) p) .
                    filter ((== b) . match cs) . lines

grep :: Bool -&gt; [String] -&gt; IO ()
grep _ []     = error &quot;Not enough arguments provided&quot;
grep b (r:ps) = either print (f ps) $ parseRegex r where
    f [] cs = grepString b Nothing cs =&lt;&lt; getLine
    f _  cs = mapM_ (\p -&gt; grepString b (Just p) cs =&lt;&lt; readFile p) ps

main :: IO ()
main = f =&lt;&lt; getArgs where
           f (&quot;-v&quot;:args) = grep False args
           f args        = grep True  args
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2009/09/25/programming-praxis-grep/" rel="nofollow">http://bonsaicode.wordpress.com/2009/09/25/programming-praxis-grep/</a> for a version with comments):</p>
<pre class="brush: css;">
import System.Environment
import Text.Printf

--Code from the previous two exercises goes here

grepString :: Bool -&gt; Maybe String -&gt; [Chunk] -&gt; String -&gt; IO ()
grepString b p cs = mapM_ (printf &quot;%s%s\n&quot; $ maybe &quot;&quot; (++ &quot;: &quot;) p) .
                    filter ((== b) . match cs) . lines

grep :: Bool -&gt; [String] -&gt; IO ()
grep _ []     = error &quot;Not enough arguments provided&quot;
grep b (r:ps) = either print (f ps) $ parseRegex r where
    f [] cs = grepString b Nothing cs =&lt;&lt; getLine
    f _  cs = mapM_ (\p -&gt; grepString b (Just p) cs =&lt;&lt; readFile p) ps

main :: IO ()
main = f =&lt;&lt; getArgs where
           f (&quot;-v&quot;:args) = grep False args
           f args        = grep True  args
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Grep &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/09/25/grep/#comment-643</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Grep &#171; Bonsai Code]]></dc:creator>
		<pubDate>Fri, 25 Sep 2009 16:50:39 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1363#comment-643</guid>
		<description><![CDATA[[...] today&#8217;s Programming Praxis exercise we&#8217;re supposed to implement grep based on the regex matching [...]]]></description>
		<content:encoded><![CDATA[<p>[...] today&#8217;s Programming Praxis exercise we&#8217;re supposed to implement grep based on the regex matching [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

