Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --aliases for code understanding
- type Bracket = Float
- type BaseTax = Float
- type Percent = Float
- --We don't care about income at this time, because the user will provide it
- --this data type maybe could just be used for everything?
- --is there a better way to do this?
- data Info = Info [Bracket] [BaseTax] Rate
- data Rate = Rate [Percent]
- -- percentage taken out after base tax
- rates = Rate [0.0, 0.28, 0.31, 0.36, 0.396]
- -- info for various tax types
- married = Info [0, 36900, 89150, 140000, 250000] [0, 5535, 20165, 35928.5, 75528.5] rates
- hoh = Info [0, 29600, 76400, 127500, 250000] [0, 4440, 17544, 33385, 77485] rates
- unmarried = Info [0, 22100, 53500, 115000, 250000] [0, 3315, 12107, 31172, 79772] rates
- marrseper = Info [0, 18450, 44575, 70000, 125000] [0, 2767.5, 10085.5, 17964.25, 37764.25] rates
- estate = Info [0, 1500, 3500, 5500, 7500] [0, 225, 785, 1405, 2125] rates
- --How do I compare income to the list? map filter (income) over Info?
- --I'm trying to compare the income to the Bracket field of the Info type.
- --I want to use the relevant fields for each bracket based upon the result
- --in C++ I'd create a class that contained each field, and directly reference that object when discovered
- --Return pair is the post tax income, the Bool is whether or not that is greater than post tax income in previous bracket
- getRaise :: Float -> Info -> (Float, Bool)
- getRaise income info =
- | income >= info
- --function works as intended, but may need to fix to accommodate taking only income (intent of function above)
- taxes :: Float -> Bracket -> BaseTax -> Percent -> Bool
- taxes income bracket c1 c2 = if over-c1 >= income - (c2*income - c2*c1 + c1)
- then False
- else True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement