Skip to content

Instantly share code, notes, and snippets.

@jmnsf
Created December 20, 2015 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmnsf/52263800cb497f4c1624 to your computer and use it in GitHub Desktop.
Save jmnsf/52263800cb497f4c1624 to your computer and use it in GitHub Desktop.
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