Task

Create a function which takes in a variable number of arguments and prints each one on its own line.

Also show, if possible in your language, how to call the function on a list of arguments constructed at runtime.



Functions of this type are also known as Variadic Functions.



Related task

   Call a function


get "libhdr"
 
// A, B, C, etc are dummy arguments. If more are needed, more can be added.
// Eventually you will run into the compiler limit. 
let foo(num, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) be
    // The arguments can be indexed starting from the first one. 
    for i=1 to num do writef("%S*N", (@num)!i)
 
// You can pass as many arguments as you want. The declaration above guarantees
// that at least the first 16 arguments (including the number) will be available,
// but you certainly needn't use them all. 
let start() be
    foo(5, "Mary", "had", "a", "little", "lamb")