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


 
Module CheckIt {
      \\ Works for numbers and strings (letters in M2000)
      Function Variadic {
            \\ print a letter for each type in function stack
            Print Envelope$()
            \\Check types using Match
            Print Match("NNSNNS")
            =stack.size
            While not Empty {
                  if islet then {print letter$} else print number
            }
      }
      M=Variadic(1,2,"Hello",3,4,"Bye")
      Print M
      \\ K is a poiner to Array
      K=(1,2,"Hello 2",3,4,"Bye 2")
      \\ !K pass all items to function's stack
      M=Variadic(!K)
}
Checkit
 
 
Module CheckIt2 {
      Function Variadic {
            \\ [] return a pointer to stack, and leave a new stack as function's stack
            a=[]
            \\ a is a pointer to stack
            \\ objects just leave a space, and cursor move to next column (spread on lines)
            Print a
      }
      M=Variadic(1,2,"Hello",3,4,"Bye")
      Print M
      \\ K is a poiner to Array
      K=(1,2,"Hello 2",3,4,"Bye 2")
      \\ !K pass all items to function stack
      M=Variadic(!K)
}
Checkit2
 