Last active
January 29, 2017 16:37
-
-
Save jdh30/fa0c58d4d7fe4cffd335b026b7d43419 to your computer and use it in GitHub Desktop.
My OCaml solution to the Cleaner Code challenge (https://www.codeproject.com/articles/1083348/csharp-bad-practices-learn-how-to-make-a-good-code)
This file contains 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
let accountFactor = function | |
| `Simple -> 0.9 | |
| `Valuable -> 0.7 | |
| `MostValuable -> 0.5 | |
let loyaltyFactor years = | |
1.0 -. float(min years 5) /. 100.0 | |
let applyDiscount price = function | |
| `Unregistered -> price | |
| `Registered(kind, years) -> | |
price *. accountFactor kind *. loyaltyFactor years | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment