source: doc/papers/concurrency/examples/Fib.py @ d2b5d2d

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since d2b5d2d was a573c22, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

example programs updated for concurrency paper

  • Property mode set to 100644
File size: 326 bytes
RevLine 
[e73d449]1def Fib():
[2e041e27]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
[e73d449]7f1 = Fib()
8f2 = Fib()
[2e041e27]9for i in range( 10 ):
10        print( next( f1 ), next( f2 ) )  # resume
11
12# Local Variables: #
13# tab-width: 4 #
[a573c22]14# compile-command: "python3.7 Fib.py" #
[2e041e27]15# End: #
Note: See TracBrowser for help on using the repository browser.