Created
December 20, 2015 22:47
-
-
Save jmnsf/52263800cb497f4c1624 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
ptSalary :: (Ord a, Fractional a) => a -> a | |
ptSalary yearly = | |
let levels = [((0, 7000), 0.145), ((7001, 20000), 0.285), ((20001, 40000), 0.37), ((40001, 80000), 0.45), ((80001, 250000), 0.505)] | |
leftVal el = fst . fst $ el | |
rightVal el = snd . fst $ el | |
pct el = snd el | |
reducer sal el = sal - (min (rightVal el - leftVal el) (yearly - leftVal el)) * pct el | |
validLevels levels = takeWhile ((< yearly) . leftVal) levels | |
in foldl reducer yearly (validLevels levels) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment