Fibonacci numbers in Nimrod

Example for versions Nimrod 0.8.8

This example uses iterative calculation of Fibonacci numbers. A single var keyword can declare several variables if they are indented to form a block. Note that variable type can be omitted from the declaration only if it is initialized immediately; Nimrod uses local type inference, not global one.

for i in 1..16 is an alternate form of writing countup loop. & is string concatenation operator, and $ is number-to-string conversion.

var
  f1 = 1
  f2 = 1
  f3: int
  res = ""
for i in 1..16:
  res = res & $f1 & ", "
  f3 = f1 + f2
  f1 = f2
  f2 = f3
echo res & "..."