<?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: Scripting Games in Haskell</title>
	<atom:link href="http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/</link>
	<description>Because my LiveJournal is too silly</description>
	<lastBuildDate>Sat, 17 Sep 2011 02:28:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Michi</title>
		<link>http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/comment-page-1/#comment-83370</link>
		<dc:creator>Michi</dc:creator>
		<pubDate>Tue, 26 Feb 2008 18:03:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/#comment-83370</guid>
		<description>Alistair: You might want to look into F#. I haven&#039;t yet, but it&#039;s a seriously functional language, integrated in the .NET Framework. Its development group is backed by some of the Great Minds behind Haskell.</description>
		<content:encoded><![CDATA[<p>Alistair: You might want to look into F#. I haven&#8217;t yet, but it&#8217;s a seriously functional language, integrated in the .NET Framework. Its development group is backed by some of the Great Minds behind Haskell.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alistair Young</title>
		<link>http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/comment-page-1/#comment-83369</link>
		<dc:creator>Alistair Young</dc:creator>
		<pubDate>Tue, 26 Feb 2008 17:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/#comment-83369</guid>
		<description>I have to poke around for functional language ports to the .NET Framework some more.  They make the code so much more short and elegant.</description>
		<content:encoded><![CDATA[<p>I have to poke around for functional language ports to the .NET Framework some more.  They make the code so much more short and elegant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pistahh</title>
		<link>http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/comment-page-1/#comment-81751</link>
		<dc:creator>Pistahh</dc:creator>
		<pubDate>Thu, 21 Feb 2008 12:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/#comment-81751</guid>
		<description>Just for reference, here is my python solution :)

cards = [(1,7),(0,5),(3,7),(2,7),(2,13)]
print sum([(n*(n-1)/2) for n in [[l for _,l in cards].count(x) for x in xrange(1,14)] if n&gt;1])</description>
		<content:encoded><![CDATA[<p>Just for reference, here is my python solution <img src='http://blog.mikael.johanssons.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>cards = [(1,7),(0,5),(3,7),(2,7),(2,13)]<br />
print sum([(n*(n-1)/2) for n in [[l for _,l in cards].count(x) for x in xrange(1,14)] if n&gt;1])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bas van Dijk</title>
		<link>http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/comment-page-1/#comment-81713</link>
		<dc:creator>Bas van Dijk</dc:creator>
		<pubDate>Thu, 21 Feb 2008 10:01:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mikael.johanssons.org/archive/2008/02/scripting-games-in-haskell/#comment-81713</guid>
		<description>I also like the following:
&lt;code&gt;
import Data.List (sort, group)

cards :: [(Int, Int)]
cards = [(1,7),(0,5),(3,7),(2,7),(2,13)]

pairs :: [(Int, Int)] -&gt; Int
pairs = sum . map ((`choose` 2) . length) . group . sort . map snd


-- &#124; Binomial coefficient
-- http://en.wikipedia.org/wiki/Binomial_coefficient
choose :: (Integral a) =&gt; a -&gt; a -&gt; a
n `choose` k &#124; n &gt;= k &amp;&amp; k &gt;= 0 = fac n `div` (fac k * fac (n - k))
             &#124; otherwise        = 0

fac :: (Num t) =&gt; t -&gt; t
fac 0 = 1
fac n = n * fac (n-1)
&lt;/code&gt;

(&#039;choose&#039; and &#039;fac&#039; don&#039;t actually belong in this script but should be part of a larger mathematical library.)</description>
		<content:encoded><![CDATA[<p>I also like the following:<br />
<code><br />
import Data.List (sort, group)</p>
<p>cards :: [(Int, Int)]<br />
cards = [(1,7),(0,5),(3,7),(2,7),(2,13)]</p>
<p>pairs :: [(Int, Int)] -&gt; Int<br />
pairs = sum . map ((`choose` 2) . length) . group . sort . map snd</p>
<p>-- | Binomial coefficient<br />
-- <a href="http://en.wikipedia.org/wiki/Binomial_coefficient" rel="nofollow">http://en.wikipedia.org/wiki/Binomial_coefficient</a><br />
choose :: (Integral a) =&gt; a -&gt; a -&gt; a<br />
n `choose` k | n &gt;= k &amp;&amp; k &gt;= 0 = fac n `div` (fac k * fac (n - k))<br />
             | otherwise        = 0</p>
<p>fac :: (Num t) =&gt; t -&gt; t<br />
fac 0 = 1<br />
fac n = n * fac (n-1)<br />
</code></p>
<p>(&#8216;choose&#8217; and &#8216;fac&#8217; don&#8217;t actually belong in this script but should be part of a larger mathematical library.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

