Last active
May 4, 2018 14:02
-
-
Save MachinesAreUs/df517ca5e7e474ebdfafae2b0216abbb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Problem 1 | |
| --------- | |
| Pragmatic Bookshelf has offices in Texas (TX) and North Carolina (NC), | |
| so we have to charge sales tax on orders shipped to these states. The | |
| rates can be expressed as a keyword list | |
| ```elxir | |
| tax_rates = [ NC: 0.075, TX: 0.08 ] | |
| ``` | |
| Here’s a list of orders: | |
| ```elixir | |
| orders = [ | |
| [ id: 123, ship_to: :NC, net_amount: 100.00 ], | |
| [ id: 124, ship_to: :OK, net_amount: 35.50 ], | |
| [ id: 125, ship_to: :TX, net_amount: 24.00 ], | |
| [ id: 126, ship_to: :TX, net_amount: 44.80 ], | |
| [ id: 127, ship_to: :NC, net_amount: 25.00 ], | |
| [ id: 128, ship_to: :MA, net_amount: 10.00 ], | |
| [ id: 129, ship_to: :CA, net_amount: 102.00 ], | |
| [ id: 120, ship_to: :NC, net_amount: 50.00 ] ] | |
| ``` | |
| Write a function that takes both lists and returns a copy of the orders, | |
| but with an extra field, total_amount which is the net plus sales tax. If a | |
| shipment is not to NC or TX, there’s no tax applied | |
| Problem 2 | |
| --------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment