Fibonacci numbers in Boo

Example for versions boo 0.8.2

This example shows the usage of generator fib: it initializes inner variables a and b, and after each call to generator it updates the variables and returns one of them. Function zip is a built-in which returns an IEnumerable that is a “mesh” of two IEnumerables — range and fib.

def fib():
    a, b = 0, 1
    while true:
        yield b
        a, b = b, a + b
 
s=""
for i, n in zip(range(16), fib()):
    s = s+n+", "
print(s+"...")