Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save etrepum/251032 to your computer and use it in GitHub Desktop.
Save etrepum/251032 to your computer and use it in GitHub Desktop.
update(Tag, NewVal, State) ->
NewTree =
case gb_trees:lookup(Tag, State#state.tree) of
{value, Val} ->
X = Val + (NewVal - Val) * 0.01,
gb_trees:update(Tag, X, State#state.tree);
none ->
gb_trees:insert(Tag, NewVal, State#state.tree)
end,
State#state{tree = NewTree}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment