source: doc/papers/concurrency/examples/Fib.py @ 76f7fc7

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 76f7fc7 was e73d449, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

formatting

  • Property mode set to 100644
File size: 328 bytes
Line 
1def Fib():
2        fn = 0; fn1 = fn; yield fn  # suspend
3        fn = 1; fn2 = fn1; fn1 = fn; yield fn
4        while True:
5                fn = fn1 + fn2; fn2 = fn1; fn1 = fn; yield fn
6
7
8
9f1 = Fib()
10f2 = Fib()
11for i in range( 10 ):
12        print( next( f1 ), next( f2 ) )  # resume
13
14# Local Variables: #
15# tab-width: 4 #
16# compile-command: "python3.5 Fib.py" #
17# End: #
Note: See TracBrowser for help on using the repository browser.