Ignore:
Timestamp:
Feb 6, 2020, 10:27:01 AM (22 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
53a49cc
Parents:
b0795be
Message:

example programs updated for concurrency paper

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/concurrency/examples/Format.py

    rb0795be ra573c22  
    44                        for g in range( 5 ):    # groups of 5 blocks
    55                                for b in range( 4 ): # blocks of 4 characters
    6                                         print( (yield), end='' ) # receive from send
     6                                        while True:
     7                                                ch = (yield) # receive from send
     8                                                if '\n' not in ch:
     9                                                        break
     10                                        print( ch, end='' ) # receive from send
    711                                print( '  ', end='' ) # block separator
    812                        print()                                 # group separator
     
    1115                        print()
    1216
     17input = "abcdefghijklmnop\nqrstuvwx\nyzxxxxxxxxxxxxxx\n"
     18
    1319fmt = Format()
    1420next( fmt )                                                     # prime generator
    15 for i in range( 41 ):
    16         fmt.send( 'a' );                                # send to yield
     21for i in input:
     22        fmt.send( i );                          # send to yield
    1723
    1824# Local Variables: #
    1925# tab-width: 4 #
    20 # compile-command: "python3.5 Format.py" #
     26# compile-command: "python3.7 Format.py" #
    2127# End: #
Note: See TracChangeset for help on using the changeset viewer.