|
Contents | Previous | Next | Subchapters |
| Syntax |
function argument name
|
| See Also | arguments , strings to functions |
clear
function trigdeg(function trigfun, degrees) begin
rad = PI * degrees / 180
return trigfun(rad)
end
function secant(x) begin
return 1. / cos(x)
end
you can then find the secant of 45 degrees by entering
print trigdeg(function secant, 45)
to which O-Matrix will respond
1.41421
Only user-defined functions can be arguments.
For example, to use the sin function as an argument,
you must make it a user-defined function.
If you enter
function sine(x) begin
return sin(x)
end
you then can find the sine of 45 degrees by entering
print trigdeg(function sine, 45)
to which O-Matrix will respond
0.707107
If a function is an argument,
it cannot be accessed using
arg
notation.
If you continue the example above by entering
function h() begin
print arg(1)
end
h(function secant)
O-Matrix will respond with an error message.