Created
November 30, 2017 20:12
-
-
Save cmbrown1598/c59fabe169ca988c71f5aead72fd3abf to your computer and use it in GitHub Desktop.
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
type Compounding = | |
| TimesPerYear of float | |
| Constant | |
type InterestCalculationOptions = { | |
Compounding : Compounding | |
Rate : float | |
Principal : float | |
TermInYears : float | |
} | |
let compound options = | |
let core r e = | |
options.Principal * (r ** e) | |
match options.Compounding with | |
| Constant -> core System.Math.E (options.Rate * options.TermInYears) | |
| TimesPerYear f -> let rate = options.Rate / f | |
core (1.0 + rate) (f * options.TermInYears) | |
let fry = compound { Compounding = TimesPerYear 1.0 | |
Rate = 0.0225 | |
Principal = 0.93 | |
TermInYears = 1000.0 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment