Skip to content

Instantly share code, notes, and snippets.

@gertjana
Created June 9, 2021 15:10
Show Gist options
  • Save gertjana/dd5b863cae78c9d3f930d040c54baf7f to your computer and use it in GitHub Desktop.
Save gertjana/dd5b863cae78c9d3f930d040c54baf7f to your computer and use it in GitHub Desktop.
deltas = loop([], nil, measurements)
defp loop(acc, prev, list) do
case list do
[] -> acc
[head | tail] when prev == nil -> loop(acc, head, tail)
[head | tail] ->
delta = (head.value - prev.value) / diff_string_date(prev.date, head.date)
loop([delta | acc], head, tail)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment