Created
August 17, 2009 09:10
-
-
Save harukizaemon/169010 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
taxRate threshold rate (total, amount) | |
| amount > threshold = (total + (amount - threshold) * rate, threshold) | |
| otherwise = (total, 0) | |
taxTable = [taxRate 60000 0.45, taxRate 30000 0.30, taxRate 15000 0.15] | |
tax amount = fst (calc(0, amount) taxTable) | |
where calc (total, remainder) [] = (total, remainder) | |
calc (total, remainder) (f:fs) = calc (f (total, remainder)) fs | |
> tax 72000 | |
=> 16500.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment