Rosetta Code – Day of the week in F#

I think the best way of mastering a language is always by solving code challenges. And here is a simple one http://rosettacode.org/wiki/Day_of_the_week and the problem is

A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).

In what years between 2008 and 2121 will the 25th of December be a Sunday?

Here is my solution in F#

open System
[2008..((2121-2007)+ 2007)] |>
 List.map(fun d -> new DateTime(d,12,25)) |>
 List.filter( fun d -> d.DayOfWeek = DayOfWeek.Sunday) |>
 List.iter( fun d -> printfn " %O" d)

It is very similar to Linq, but the difference between F# and C# is essence versus ceremony.

2 thoughts on “Rosetta Code – Day of the week in F#

  1. Pingback: DotNetShoutout

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s