Fibonacci numbers in Nemerle

Example for versions ncc 0.9.3

This example uses recursive definition of Fibonacci numbers, expressed in functional style. Note the definition of loop counter i — keyword mutable, as opposed to regular def, means that the value of the variable is going to change.

def fib(i)
{
  | x when x<2 => 1
  | _          => fib(i - 2) + fib(i - 1)
}
 
mutable i=0;
while (i<16)
{   System.Console.Write("{0}, ", fib(i));
    i++;
}
System.Console.WriteLine("...");