### 11.4.1 Define a function with a variable number of arguments: args

The args (or args(NULL)) command returns the list of arguments of a function. The element at index 0 is the name of the function, the remaining are the arguments passed to the function. This allows you to define functions with a variable number of arguments.

Note that args() will not work, the command must be called as args or args(NULL). You can also use (args)[0] to get the name of the function and (args)[1] to get the first argument, etc., but the parentheses about args is mandatory.

Input:

testargs() := local y; y := args; return y[1];

then:

testargs(12,5)

Output:

12

Input:

    total():={
     local s,a;
     a:=args;
     s:=0;
     for (k:=1;k<size(a);k++){
     s:=s+a[k];
     }
     return s;
     }

then:

total(1,2,3,4)

Output:

10