Created
June 9, 2021 15:11
-
-
Save gertjana/1e85ed3c753039f55e81658e71c17e96 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
deltas = loop([], nil, measurements) | |
defp loop(acc, _, []), do: acc | |
defp loop(acc, nil, [head | tail]), do: loop(acc, head, tail) | |
defp loop(acc, prev, [head | tail]) do | |
diff = (head.value - prev.value) / diff_string_date(prev.date, head.date) | |
loop([diff | acc], head, tail) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment