Skip to content

Instantly share code, notes, and snippets.

@gertjana
Created June 9, 2021 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gertjana/1e85ed3c753039f55e81658e71c17e96 to your computer and use it in GitHub Desktop.
Save gertjana/1e85ed3c753039f55e81658e71c17e96 to your computer and use it in GitHub Desktop.
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