- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/FibRefactor.py
re73d449 r90b9e4b 1 def Fib ():1 def Fibonacci(): 2 2 def Refactor(): 3 nonlocal fn, fn1 3 nonlocal fn, fn1, fn2 4 4 fn = 0; fn1 = fn 5 5 yield fn # suspend 6 7 6 def Refactor2(): 8 7 nonlocal fn, fn1, fn2 … … 15 14 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; yield fn 16 15 17 f1 = Fib ()18 f2 = Fib ()16 f1 = Fibonacci() 17 f2 = Fibonacci() 19 18 for i in range( 10 ): 20 19 print( next( f1 ), next( f2 ) ) # resume
Note: See TracChangeset
for help on using the changeset viewer.