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:
Input:
f(x,y=5,z):= { |
return x*y*z; |
}
|
then:
Input:
Output:
6 |
since the product 1*2*3=6. If you give f only two
values as input:
Input:
Output:
60 |
since the values 3 and 4 will be given to the parameters which don’t 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.