<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>porges &#187; fizzbuzz</title>
	<atom:link href="http://porg.es/blog/tag/fizzbuzz/feed" rel="self" type="application/rss+xml" />
	<link>http://porg.es/blog</link>
	<description></description>
	<lastBuildDate>Thu, 12 Jan 2012 23:45:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Overengineering</title>
		<link>http://porg.es/blog/overengineering</link>
		<comments>http://porg.es/blog/overengineering#comments</comments>
		<pubDate>Wed, 27 Feb 2008 00:55:09 +0000</pubDate>
		<dc:creator>Porges</dc:creator>
				<category><![CDATA[replies]]></category>
		<category><![CDATA[fizzbuzz]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[horrid]]></category>
		<category><![CDATA[humour]]></category>
		<category><![CDATA[overengineered]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://porg.es/blog/overengineering</guid>
		<description><![CDATA[Douglas, you&#8217;re not alone. import Data.List &#40;sortBy&#41; import Data.Function &#40;on&#41; import Data.Maybe &#40;mapMaybe&#41; import Control.Monad.Instances &#160; gizzabuzz pairs combiner = zipWith &#40;$&#41; &#40;cycle funcs&#41; &#91;1..&#93; where sortedPairs = sortBy &#40;compare `on` fst&#41; pairs funcs = map &#40;\n -&#62; display $ mapMaybe &#40;filterOut n&#41; sortedPairs&#41; &#91;1..foldr1 lcm $ map fst $ sortedPairs&#93; display &#91;&#93; = show [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dougalstanton.net/blog/index.php/2008/02/26/my-shame-is-complete">Douglas</a>, you&#8217;re not alone.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> Data<span style="color: #339933; font-weight: bold;">.</span>List <span style="color: green;">&#40;</span>sortBy<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> Data<span style="color: #339933; font-weight: bold;">.</span>Function <span style="color: green;">&#40;</span>on<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> Data<span style="color: #339933; font-weight: bold;">.</span><span style="color: #cccc00; font-weight: bold;">Maybe</span> <span style="color: green;">&#40;</span>mapMaybe<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span><span style="color: #cccc00; font-weight: bold;">Monad</span><span style="color: #339933; font-weight: bold;">.</span>Instances
&nbsp;
gizzabuzz pairs combiner <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">zipWith</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">$</span><span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span><span style="font-weight: bold;">cycle</span> funcs<span style="color: green;">&#41;</span> <span style="color: green;">&#91;</span><span style="color: red;">1</span><span style="color: #339933; font-weight: bold;">..</span><span style="color: green;">&#93;</span>
	<span style="color: #06c; font-weight: bold;">where</span> 
	sortedPairs <span style="color: #339933; font-weight: bold;">=</span> sortBy <span style="color: green;">&#40;</span><span style="font-weight: bold;">compare</span> `on` <span style="font-weight: bold;">fst</span><span style="color: green;">&#41;</span> pairs
	funcs <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">map</span> <span style="color: green;">&#40;</span>\n <span style="color: #339933; font-weight: bold;">-&gt;</span> display <span style="color: #339933; font-weight: bold;">$</span> mapMaybe <span style="color: green;">&#40;</span>filterOut n<span style="color: green;">&#41;</span> sortedPairs<span style="color: green;">&#41;</span> <span style="color: green;">&#91;</span><span style="color: red;">1</span><span style="color: #339933; font-weight: bold;">..</span><span style="font-weight: bold;">foldr1</span> <span style="font-weight: bold;">lcm</span> <span style="color: #339933; font-weight: bold;">$</span> <span style="font-weight: bold;">map</span> <span style="font-weight: bold;">fst</span> <span style="color: #339933; font-weight: bold;">$</span> sortedPairs<span style="color: green;">&#93;</span>
	display <span style="color: green;">&#91;</span><span style="color: green;">&#93;</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">show</span>
	display xs <span style="color: #339933; font-weight: bold;">=</span> <span style="font-weight: bold;">foldr1</span> combiner <span style="color: #339933; font-weight: bold;">.</span> <span style="font-weight: bold;">sequence</span> <span style="color: green;">&#40;</span><span style="font-weight: bold;">map</span> <span style="font-weight: bold;">const</span> xs<span style="color: green;">&#41;</span>
	filterOut n <span style="color: green;">&#40;</span>x<span style="color: #339933; font-weight: bold;">,</span>y<span style="color: green;">&#41;</span>
		<span style="color: #339933; font-weight: bold;">|</span> n `<span style="font-weight: bold;">mod</span>` x <span style="color: #339933; font-weight: bold;">==</span> <span style="color: red;">0</span> <span style="color: #339933; font-weight: bold;">=</span> Just y
		<span style="color: #339933; font-weight: bold;">|</span> <span style="font-weight: bold;">otherwise</span>      <span style="color: #339933; font-weight: bold;">=</span> Nothing
&nbsp;
fizzbuzz <span style="color: #339933; font-weight: bold;">=</span> gizzabuzz <span style="color: green;">&#91;</span><span style="color: green;">&#40;</span><span style="color: red;">3</span><span style="color: #339933; font-weight: bold;">,</span><span style="background-color: #3cb371;">&quot;Fizz&quot;</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: green;">&#40;</span><span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">,</span><span style="background-color: #3cb371;">&quot;Buzz&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span> <span style="color: green;">&#40;</span><span style="color: #339933; font-weight: bold;">++</span><span style="color: green;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://porg.es/blog/overengineering/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

