Skip to content

Instantly share code, notes, and snippets.

@mwlang
Created May 5, 2019 11:51
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 mwlang/907f9b5bb100bead8240e7d17481a85b to your computer and use it in GitHub Desktop.
Save mwlang/907f9b5bb100bead8240e7d17481a85b to your computer and use it in GitHub Desktop.
def prev(offset)
@points.prev offset
end
macro prev_value(offset, source)
@points.prev({{offset}}).{{source}}
end
def weighted_average(source, value=nil)
[ 4.0 * (value || prev_value(0, source)),
3.0 * prev_value(1, source),
2.0 * prev_value(2, source),
prev_value(3, source),
].sum / 10.0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment