ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since 033ff37 was 2e041e27, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago |
add examples directory for testing code in the paper
|
-
Property mode
set to
100644
|
File size:
547 bytes
|
Rev | Line | |
---|
[2e041e27] | 1 | def Format():
|
---|
| 2 | try:
|
---|
| 3 | while True:
|
---|
| 4 | for g in range( 5 ): # groups of 5 blocks
|
---|
| 5 | for b in range( 4 ): # blocks of 4 characters
|
---|
| 6 | print( (yield), end='' ) # receive from send
|
---|
| 7 | print( ' ', end='' ) # block separator
|
---|
| 8 | print() # group separator
|
---|
| 9 | except GeneratorExit: # destructor
|
---|
| 10 | if g != 0 | b != 0: # special case
|
---|
| 11 | print()
|
---|
| 12 |
|
---|
| 13 | fmt = Format()
|
---|
| 14 | next( fmt ) # prime generator
|
---|
| 15 | for i in range( 41 ):
|
---|
| 16 | fmt.send( 'a' ); # send to yield
|
---|
| 17 |
|
---|
| 18 | # Local Variables: #
|
---|
| 19 | # tab-width: 4 #
|
---|
| 20 | # compile-command: "python3.5 Format.py" #
|
---|
| 21 | # End: #
|
---|
Note:
See
TracBrowser
for help on using the repository browser.