Skip to content

Instantly share code, notes, and snippets.

@trescenzi
Created August 18, 2015 22:13
Show Gist options
  • Save trescenzi/cc485fbddcf65301afc0 to your computer and use it in GitHub Desktop.
Save trescenzi/cc485fbddcf65301afc0 to your computer and use it in GitHub Desktop.
def interest_calc(initial_amount, interest, monthly_addition, months) do
Stream.unfold(initial_amount, fn x ->
month_end_principle = x + monthly_addition
new_principle = month_end_principle * (1 + (interest/12))
{new_principle, new_principle}
end) |> Enum.take(months)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment