Fibonacci numbers in S-lang

Example for versions S-lang 2.2.2

This example uses iterative definition of Fibonacci numbers and shows some more features of array processing in S-lang. f is explicitly declared as an array of 16 integer numbers. Elements 0 and 1 of f are set to 1; here [0:1] creates a list of indices to which the operation is applied. Intrinsic function string converts its argument to its string representation.

f = Integer_Type [16];
f[[0:1]] = 1;
for (i=2; i<16; i++)
    f[i] = f[i-1] + f[i-2];
s = "...";
for (i=15; i>=0; i--)
    s = string(f[i]) + ", " + s;
message (s);