Your Turn

  • Exercise: ListsAndRecursion-8

    The 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:[17]

     
    tax_rates = [ NC: 0.075, TX: 0.08 ]

    Here’s a list of orders:

     
    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, ...

Get Programming Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.