<commit_before>defmodule Tax do
  def tax_ins(rates, orders), do: orders |> Stream.map(fn v -> tax_in(rates, v, v[:ship_to]) end) |> Enum.to_list
  defp tax_in(rates, order, state) when state == :NC, do: Keyword.update!(order, :net_amount, fn v -> v * (1 + rates[state]) end)
  defp tax_in(rates, order, state) when state == :TX, do: Keyword.update!(order, :net_amount, fn v -> v * (1 + rates[state]) end)
  defp tax_in(_, order, _), do: order
end

tax_rates = [ NC: 0.075, TX: 0.08 ]
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: 130, ship_to: :NC, net_amount: 50.00 ]]

IO.inspect Tax.tax_ins(tax_rates, orders)<commit_msg>update ListsAndRecursion-8<commit_after>defmodule Tax do
  def tax_ins(rates, orders), do: orders |> Stream.map(fn v -> tax_in(v, rates, v[:ship_to]) end) |> Enum.to_list
  defp tax_in(order, rates, state) when state == :NC, do: Keyword.update!(order, :net_amount, fn v -> v * (1 + rates[state]) end)
  defp tax_in(order, rates, state) when state == :TX, do: Keyword.update!(order, :net_amount, fn v -> v * (1 + rates[state]) end)
  defp tax_in(order,_ , _), do: order
end

tax_rates = [ NC: 0.075, TX: 0.08 ]
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: 130, ship_to: :NC, net_amount: 50.00 ]]

IO.inspect Tax.tax_ins(tax_rates, orders)
# [[id: 123, ship_to: :NC, net_amount: 107.5],
#  [id: 124, ship_to: :OK, net_amount: 35.5],
#  [id: 125, ship_to: :TX, net_amount: 25.92],
#  [id: 126, ship_to: :TX, net_amount: 48.384],
#  [id: 127, ship_to: :NC, net_amount: 26.875],
#  [id: 128, ship_to: :MA, net_amount: 10.0],
#  [id: 129, ship_to: :CA, net_amount: 102.0],
#  [id: 130, ship_to: :NC, net_amount: 53.75]]
{'fraction_non_alphanumeric': 0.19371959310039805, 'fraction_numerical': 0.08447589562140646, 'mean_word_length': 4.049107142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6790406', 'n_tokens_mistral': 1139, 'n_tokens_neox': 970, 'n_words': 267}