source: doc/papers/concurrency/examples/Fib.py@ 9131e54

ADT arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 9131e54 was e73d449, checked in by Peter A. Buhr <pabuhr@…>, 7 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.