Last active
January 20, 2017 19:14
-
-
Save jasondown/3003fc286c8f3d3b462f868c6c318a2f to your computer and use it in GitHub Desktop.
Multiple-Case Active Pattern, Decomposition
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
| open System | |
| let (|Spring|Summer|Fall|Winter|) (date : DateTime) = | |
| match date.Month, date.Day with | |
| | 1, _ | 2, _ -> Winter | |
| | 3, d when d < 21 -> Winter | |
| | 3, _ | 4, _ | 5, _ -> Spring | |
| | 6, d when d < 21 -> Spring | |
| | 6, _ | 7, _ | 8, _ -> Summer | |
| | 9, d when d < 21 -> Summer | |
| | 9, _ | 10, _ | 11, _ -> Fall | |
| | 12, d when d < 21 -> Fall | |
| | _ -> Winter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment