Skip to content

Instantly share code, notes, and snippets.

@poros
Created October 4, 2015 16:31
Show Gist options
  • Save poros/d6a4a19aa58811588d0c to your computer and use it in GitHub Desktop.
Save poros/d6a4a19aa58811588d0c to your computer and use it in GitHub Desktop.
Update multiple state variables at once
def fibonacci(n):
x = 0
y = 1
for i in range(n):
print x
tmp = y
y = x + y
x = tmp
def fibonacci(n):
x, y = 0, 1
for i in range(n):
print x
x, y = y, x + y
# one more example
tmp_x = x + dx * t
tmp_y = y + dy * t
tmp_dx = influence(m, x, y, dx, dy, partial='x')
tmp_dy = influnence(m, x, y, dx, dy, partial='y')
x = tmp_x
y = tmp_y
dx = tmp_dx
dy = tmp_dy
x, y, dx, dy = (
x + dx * t,
y + dy * t,
influence(m, x, y, dx, dy, partial='x'),
influnence(m, x, y, dx, dy, partial='y'),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment