Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simon Cousins Israel Tax Solution in F#
(* http://www.simontylercousins.netsolution to http://ayende.com/blog/108545/the-tax-calculation-challenge *)
let taxes salary =
let rates = [
40230.0m,0.45m;
21240.0m,0.33m;
14070.0m,0.3m;
8660.0m,0.23m;
5070.0m,0.14m;
0.0m,0.1m]
let taxAtRate (tax,remainder) (threshold,rate) =
let taxable = remainder - threshold
if taxable > 0.0m
then tax + rate * taxable, remainder - taxable
else tax,remainder
List.fold taxAtRate (0.0m, salary) rates |> fst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.