Skip to content

Instantly share code, notes, and snippets.

@jdh30
Created January 28, 2017 03:34
Show Gist options
  • Save jdh30/b01279a6be91467c5887b72a7c2f303e to your computer and use it in GitHub Desktop.
Save jdh30/b01279a6be91467c5887b72a7c2f303e to your computer and use it in GitHub Desktop.
type AccountKind = Simple | Valuable | MostValuable
type CustomerStatus =
| Unregistered
| Registered of AccountKind * Years:int
let accountFactor kind =
match kind with
| Simple -> 0.9m
| Valuable -> 0.7m
| MostValuable -> 0.5m
let loyaltyFactor years =
1m - decimal(min years 5) / 100m
let applyDiscount price status =
match status with
| Unregistered -> price
| Registered(kind, years) ->
price * accountFactor kind * loyaltyFactor years
@aaron-makowski
Copy link

aaron-makowski commented Jun 29, 2020

also make
price * accountFactor kind * loyaltyFactor years
into
price * accountFactor(kind) * loyaltyFactor(years)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment