Functional Operators
Description
Examples
A functional operator in Maple is a special form of a procedure. Functional operators are written using arrow notation.
vars→result
Here, vars is a sequence of variable names (or a single variable) and result is the result of the procedure acting on vars.
For example, the following
x→x2
represents the function that squares its argument.
Multivariate and vector functions are also allowed. You must put parentheses around vars or result whenever they are expression sequences. For example, the following functions have the correct syntax.
x,y→x2+y2
x→2⁢x,3⁢x4
x,y,z→x⁢y,y⁢z
You can also create a functional operator by using the unapply command. (See unapply.)
A functional operator of the form:
is semantically equivalent to:
proc(vars) option operator, arrow; result end
The identity operator is expressed as x→x for any variable name x.
Constant operators do not simplify to numbers. For example, x→1 does not simplify to 1.
Expressions such as x→fx do not simplify to f. This is invalid if f can also take fewer or greater than one argument.
Note that optional and keyword parameters (see the paramprocessing help page for more information on these) cannot be used in functional operators. However, type specifiers for parameters are supported. If a type specifier is used, then the parameters must be enclosed in parentheses, even in the case of a single parameter.
f≔x↦3⋅x+5
f⁡2
11
g≔x,y↦sin⁡x⋅cos⁡y+y⋅x
g⁡π2,π
−1+π22
h≔x↦2⋅x,x3
h⁡3
6,27
u≔x::integer,y::integer↦x+y−igcd⁡x,y
u≔x::ℤ,y::ℤ↦x+y−igcd⁡x,y
u⁡23,4
Error, invalid input: u expects its 1st argument, x, to be of type integer, but received 2/3
See Also
@
@@
D
examples/functionaloperators
operators/D
type/operator
unapply
Download Help Document