<?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: Project Euler in F# &#8211; Problem 19</title>
	<atom:link href="http://www.fsharp.it/2008/11/19/project-euler-in-f-problem-19/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fsharp.it/2008/11/19/project-euler-in-f-problem-19/</link>
	<description>Functional programming on .Net</description>
	<lastBuildDate>Wed, 23 Mar 2011 17:29:06 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dimchansky</title>
		<link>http://www.fsharp.it/2008/11/19/project-euler-in-f-problem-19/comment-page-1/#comment-1179</link>
		<dc:creator>Dimchansky</dc:creator>
		<pubDate>Sat, 29 Nov 2008 15:55:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=64#comment-1179</guid>
		<description>My solution is:

[fsharp]
#light

let answer =
    {1901 .. 2000} &#124;&gt; 
    Seq.map (fun y -&gt; {1 .. 12} &#124;&gt; Seq.map (fun m -&gt; (y,m,1))) &#124;&gt; 
    Seq.concat &#124;&gt; 
    Seq.map (fun (y,m,d) -&gt; new System.DateTime(y,m,d)) &#124;&gt; 
    Seq.map (fun dt -&gt; dt.DayOfWeek) &#124;&gt;
    Seq.filter (fun dow -&gt; dow = System.DayOfWeek.Sunday) &#124;&gt; 
    Seq.length
[/fsharp]</description>
		<content:encoded><![CDATA[<p>My solution is:</p>
<pre class="brush: fsharp">
#light

let answer =
    {1901 .. 2000} |&gt;
    Seq.map (fun y -&gt; {1 .. 12} |&gt; Seq.map (fun m -&gt; (y,m,1))) |&gt;
    Seq.concat |&gt;
    Seq.map (fun (y,m,d) -&gt; new System.DateTime(y,m,d)) |&gt;
    Seq.map (fun dt -&gt; dt.DayOfWeek) |&gt;
    Seq.filter (fun dow -&gt; dow = System.DayOfWeek.Sunday) |&gt;
    Seq.length
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: claudio</title>
		<link>http://www.fsharp.it/2008/11/19/project-euler-in-f-problem-19/comment-page-1/#comment-1136</link>
		<dc:creator>claudio</dc:creator>
		<pubDate>Fri, 21 Nov 2008 08:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=64#comment-1136</guid>
		<description>The trick is to understand how &lt;i&gt;unfold&lt;/i&gt; works: it takes a function to be repeatedly evaluated to generate the items of a lazy list.

This function can be of any type but has to return an &lt;i&gt;option type&lt;/i&gt;, which is a union type whose members are &lt;i&gt;None&lt;/i&gt; and &lt;i&gt;Some(x)&lt;/i&gt;.

When the function returns &lt;i&gt;None&lt;/i&gt;, &lt;i&gt;unfold&lt;/i&gt; stops iterating and generating new items, but if the output is &lt;i&gt;Some(x, y)&lt;/i&gt; then &lt;i&gt;x&lt;/i&gt; is added to the lazy list as its next element while &lt;i&gt;y&lt;/i&gt; is passed to the function for the next iteration.

In the code above, for each iteration we take the current date and add one month to generate to next value to be checked.</description>
		<content:encoded><![CDATA[<p>The trick is to understand how <i>unfold</i> works: it takes a function to be repeatedly evaluated to generate the items of a lazy list.</p>
<p>This function can be of any type but has to return an <i>option type</i>, which is a union type whose members are <i>None</i> and <i>Some(x)</i>.</p>
<p>When the function returns <i>None</i>, <i>unfold</i> stops iterating and generating new items, but if the output is <i>Some(x, y)</i> then <i>x</i> is added to the lazy list as its next element while <i>y</i> is passed to the function for the next iteration.</p>
<p>In the code above, for each iteration we take the current date and add one month to generate to next value to be checked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: novice</title>
		<link>http://www.fsharp.it/2008/11/19/project-euler-in-f-problem-19/comment-page-1/#comment-1129</link>
		<dc:creator>novice</dc:creator>
		<pubDate>Thu, 20 Nov 2008 19:10:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.fsharp.it/?p=64#comment-1129</guid>
		<description>What does Some(x, x.AddMonths(1)) do? I can&#039;t seem to find any documentation for this function.</description>
		<content:encoded><![CDATA[<p>What does Some(x, x.AddMonths(1)) do? I can&#8217;t seem to find any documentation for this function.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

