Previous Up Next

25.1.4  Default values of the parameters

You can give the parameters of a function default values by putting parameter=value in the parameter list of the function. For example, if you define a function:

f(x,y=5,z):={ return x*y*z; }

then:

f(1,2,3)
     
6           

since the product 1· 2· 3=6. If you give f only two values as input:

f(3,4)
     
60           

since the values 3 and 4 will be given to the parameters which do not have default values; in this case, y will get its default value 5 while 3 and 4 will be assigned to x and z, respectively. The result is x y z=3· 5· 4=60.


Previous Up Next