Skip to content

Instantly share code, notes, and snippets.

@jasondown
Last active January 20, 2017 19:14
Show Gist options
  • Select an option

  • Save jasondown/3003fc286c8f3d3b462f868c6c318a2f to your computer and use it in GitHub Desktop.

Select an option

Save jasondown/3003fc286c8f3d3b462f868c6c318a2f to your computer and use it in GitHub Desktop.
Multiple-Case Active Pattern, Decomposition
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