March 2019
Intermediate to advanced
208 pages
5h 11m
English
Write a function named discount that calculates discount prices. It should have two labeled parameters (choose any names you like):
If the original price is, say, $30.00 and the discount percent is 5%, the amount saved is $1.50 (5% of $30.00), making the result $28.50.
Then, use currying to create functions named halfOff which uses 50 as the value for the percent, and tenPercentOff, which uses 10 as the value for the percent. Write complete type annotations on the discount function. Make sure you write code that uses these functions and displays the results so you can be sure everything works! You can see a solution at code/functions/src/Discount.re ...
Read now
Unlock full access