Skip to content

Instantly share code, notes, and snippets.

@mythz
Created September 27, 2011 04:54
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 mythz/1244370 to your computer and use it in GitHub Desktop.
Save mythz/1244370 to your computer and use it in GitHub Desktop.
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