March 2019
Intermediate to advanced
208 pages
5h 11m
English
In the United States, the standard for mortgages is a 30-year loan. If the majority of our users are in the US, we might want to provide a default of 30 for years. In order to provide default values, we need to have at least one unlabeled parameter because of the way ReasonML does currying, as described. All our parameters are labeled, so we’ll add a special parameter () called unit as an unlabeled, do-nothing parameter:
| | let payment = (~principal, ~apr, ~years=30, ()) => { |
| | let r = apr /. 12.0 /. 100.0; |
| | let n = float_of_int(years * 12); |
| | let powerTerm = (1.0 +. r) ** n; |
| | principal *. (r *. powerTerm) /. (powerTerm ... |
Read now
Unlock full access