source:
doc/papers/concurrency/examples/Fib2.py
@
a6cfb4d
Last change on this file since a6cfb4d was a573c22, checked in by , 5 years ago | |
---|---|
|
|
File size: 271 bytes |
Rev | Line | |
---|---|---|
[17c6c1c3] | 1 | def Fib(): |
[a573c22] | 2 | fn1, fn = 1, 0 |
[17c6c1c3] | 3 | while True: |
[a573c22] | 4 | yield fn |
[17c6c1c3] | 5 | fn1, fn = fn, fn1 + fn |
6 | ||
7 | f1 = Fib() | |
8 | f2 = Fib() | |
9 | for 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 Fib2.py" # |
[17c6c1c3] | 15 | # End: # |
Note: See TracBrowser
for help on using the repository browser.