Created
January 20, 2017 19:30
-
-
Save jasondown/0e46303dd97e334666a489daa8e47583 to your computer and use it in GitHub Desktop.
Multiple-Case Active Pattern, Decomposition 2
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, d | 2, d | 3, d when d < 21 -> Winter | |
| | 3, d | 4, d | 5, d | 6, d when d < 21 -> Spring | |
| | 6, d | 7, d | 8, d | 9, d when d < 21 -> Summer | |
| | 9, d | 10, d | 11, d | 12, d when d < 21 -> Fall | |
| | _ -> Winter |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This has a subtle bug as discussed in this blog post (in the UPDATE: Aug-11-2020) section: http://www.jason-down.com/2017/01/24/f-pattern-matching-part-2-active-patterns/