Skip to content

Instantly share code, notes, and snippets.

@Rickasaurus
Last active August 29, 2015 13:58
Show Gist options
  • Save Rickasaurus/9963727 to your computer and use it in GitHub Desktop.
Save Rickasaurus/9963727 to your computer and use it in GitHub Desktop.
Folding Enums in F#
type Days =
| None = 0x0
| Sunday = 0x1
| Monday = 0x2
| Tuesday = 0x4
| Wednesday = 0x8
| Thursday = 0x10
| Friday = 0x20
| Saturday = 0x40
let partyTimes = [Days.Sunday; Days.Friday; Days.Sunday] |> List.fold (|||) Days.None
(partyTimes &&& Days.Sunday) = Days.Sunday // True
(partyTimes &&& Days.Monday) = Days.Monday // False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment