Created
May 16, 2017 23:37
-
-
Save boxxxie/00177c0a46cd367d07815953da885440 to your computer and use it in GitHub Desktop.
This file contains 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
# first_year_maker = fn(path) -> | |
# fn {current_year, acc} = tuple -> | |
# acc_con = Map.get(acc, path) | |
# con = get_in(current_year, path) | |
# year = current_year.year_index | |
# case {con, acc_con} do | |
# {0.0, nil} -> tuple | |
# {nil, nil} -> tuple | |
# {nil, _} -> tuple | |
# {_, acc_con} when is_number(acc_con) -> tuple | |
# {con ,nil} when con > 0 -> {current_year, Map.put(acc, path, year)} | |
# end | |
# end | |
# end | |
# #cool | |
# rrsp_contribution = first_year_maker.([person, :accounts, :rrsp, :contribution]) | |
# tfsa_contribution = first_year_maker.([person, :accounts, :tfsa, :contribution]) | |
# non_reg_contribution = first_year_maker.([person, :accounts, :non_reg, :contribution]) | |
# result_list | |
# |> Enum.reduce(%{}, fn cur, acc -> | |
# [ | |
# rrsp_contribution, | |
# tfsa_contribution, | |
# non_reg_contribution | |
# ] | |
# |> Enum.reduce({cur, acc}, fn fun, params -> | |
# fun.(params) | |
# end) | |
# |> elem(1) | |
# end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment