source: doc/papers/concurrency/examples/Fib.py @ 81a05ca

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

add examples directory for testing code in the paper

  • Property mode set to 100644
File size: 346 bytes
Line 
1def Fibonacci():
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 = Fibonacci()
10f2 = Fibonacci()
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.