Code of the Week
Sometimes a piece of code leaves you with a sense of awe. Sometimes it is because it is so bad, sometimes it is because it is beautiful. Below is a piece of code that Cameron (AKA: ckknight) posted to the Boo mailing list. I think that this is the most succinct, beautiful and clear fib function that I've seen.
def fib():
   a, b = 0, 1
   while true:
      a, b = b, a + b
      yield a 
for item in fib():
    print item 
 

Comments
Comment preview