-
-
Save mwlang/907f9b5bb100bead8240e7d17481a85b 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
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