Created
July 14, 2014 13:12
-
-
Save PatrickMcDonald/f9bdc8e2a35392d99509 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let date year month day = new System.DateTime(year, month, day) | |
type DayOfWeek = | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday | |
exception DayOfWeekError | |
let dayOfWeek (date: System.DateTime) = | |
match date.DayOfWeek with | |
| System.DayOfWeek.Monday -> Monday | |
| System.DayOfWeek.Tuesday -> Tuesday | |
| System.DayOfWeek.Wednesday -> Wednesday | |
| System.DayOfWeek.Thursday -> Thursday | |
| System.DayOfWeek.Friday -> Friday | |
| System.DayOfWeek.Saturday -> Saturday | |
| System.DayOfWeek.Sunday -> Sunday | |
| _ -> raise DayOfWeekError | |
// Augusts with 5 3-day weekends | |
[2000 .. 3000] | |
|> List.filter (fun year -> (date year 8 1 |> dayOfWeek) = Friday) | |
|> List.iter (printf "%d; ") | |
let combine xs ys = [ for y in ys do for x in xs do yield y, x ] | |
let mmmyyyy (tw:System.IO.TextWriter) (date:System.DateTime) = tw.Write("{0:MMM yyyy}", date) | |
// Friday 13ths | |
[2014 .. 2020] | |
|> combine [1..12] | |
|> List.map (fun (year, month) -> date year month 13) | |
|> List.filter (dayOfWeek >> ((=) Friday)) | |
|> List.iter (printf "%a; " mmmyyyy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment