annotate ch2ex7.py @ 18:92e2879e2e33

Rework the red-black tree based on Julienne Walker's tutorial. Insertion is implemented now. Deletion will come next.
author Brian Neal <bgneal@gmail.com>
date Wed, 26 Dec 2012 19:59:17 -0600
parents aea27d10dd18
children
rev   line source
bgneal@10 1 """Chapter 2.7, exercise 7.
bgneal@10 2
bgneal@10 3 Write a generator that yields an infinite sequence of alpha-numeric identifiers,
bgneal@10 4 starting with a1 through z1, then a2 through z2, and so on.
bgneal@10 5
bgneal@10 6 """
bgneal@10 7 import string
bgneal@10 8
bgneal@10 9 def generate_identifier():
bgneal@10 10 num = 1
bgneal@10 11 while True:
bgneal@10 12 for c in string.lowercase:
bgneal@10 13 yield c + str(num)
bgneal@10 14 num += 1
bgneal@10 15
bgneal@10 16
bgneal@10 17 if __name__ == '__main__':
bgneal@10 18 try:
bgneal@10 19 for name in generate_identifier():
bgneal@10 20 print name
bgneal@10 21 except KeyboardInterrupt:
bgneal@10 22 print "Control-C interrupt"