Created
October 4, 2015 16:31
-
-
Save poros/d6a4a19aa58811588d0c to your computer and use it in GitHub Desktop.
Update multiple state variables at once
This file contains hidden or 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 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